C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[49447] Re:함수 포인터를 전달하는 부분에서 에러가 나는데 어찌할지요
아리랑 [interest] 1394 읽음    2007-05-29 19:41
Cannot convert 'type1' to 'type2' (E2034)

An assignment, initialization, or expression requires the specified type conversion to be performed, but the conversion is not legal.

In C++, the compiler will convert one function pointer to another only if the signature for the functions are the same. Signature refers to the arguments and return type of the function.

따라서 아래와 같이 해보면 될듯...
hKeyHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC),KeyHookProc, NULL, GetCurrentThreadId());


동철이 님이 쓰신 글 :
: LRESULT CALLBACK KeyHookProc(int nCode, WPARAM wParam, LPARAM lParam)
: {
:     HDC hdc;
:     char str[MAX_PATH];
:     RECT rt = {100, 120, 500, 150};
:     static int Count = 0;
:
:     if(nCode < 0)
:         return CallNextHookEx(hKeyHook, nCode, wParam, lParam);
:     hdc = GetDC(hWndMain);
:     wsprintf(str, "nCode = %d, wParam = %u, lParam = %08x, Count = %d",
:             nCode, wParam, lParam, Count++);
:     FillRect(hdc, &rt, (HBRUSH)GetStockObject(WHITE_BRUSH));
:     TextOut(hdc, 100, 120, str, strlen(str));
:     ReleaseDC(hWndMain, hdc);
:     return CallNextHookEx(hKeyHook, nCode, wParam, lParam);
: }
:
: LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
: {
:     HDC hdc;
:     PAINTSTRUCT ps;
:     char mes[] = "키보드 훅 테스트 프로그램이단다.";
:
:     switch(iMessage)
:     {
:         case WM_CREATE:
:             hKeyHook = SetWindowsHookEx(WH_KEYBOARD, KeyHookProc,, NULL, GetCurrentThreadId());
:             return 0;
:
:
: 다음은 에러메시지이고 위 빨간 파라메터에서 에러난게 분명한데요.
: SetWindowsHookEx의 원형은 HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId);인데 왜 이런 에러가 나는지 모르겠습니다. 어떻게 바꿔야 할지...
:
: [C++ Error] proc1.cpp(71): E2034 Cannot convert 'long (__stdcall *)(int,unsigned int,long)' to 'int (__stdcall *)()'
: [C++ Error] proc1.cpp(71): E2342 Type mismatch in parameter 'lpfn' (wanted 'int (__stdcall *)()', got 'long (__stdcall *)(int,unsigned int,long)')

+ -

관련 글 리스트
49446 함수 포인터를 전달하는 부분에서 에러가 나는데 어찌할지요 동철이 1277 2007/05/29
49447     Re:함수 포인터를 전달하는 부분에서 에러가 나는데 어찌할지요 아리랑 1394 2007/05/29
49449         고맙습니다. 근데 또 질문있습니다. 동철이 1174 2007/05/29
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.