Why I can't capture the mouse message |
答題得分者是:lcsboy
|
davidhsu
一般會員 發表:5 回覆:1 積分:1 註冊:2002-12-17 發送簡訊給我 |
Hi~
Dear Sir:
I want to capture a mouse message when I Mouse down or up,
and i also to get the position when I move it,
But I don't know why I can't capture the mouse message.
My code is as following:
Thanks~ David LRESULT CALLBACK WindowProcedureWindowSenondForImageEdit(HWND hWnd, UINT
msg,
WPARAM wParam, LPARAM lParam)
{
bool fCallDefProc=false;
LRESULT lresult;
switch(msg)
{
case WM_NCHITTEST: //sent to a window when the cursor moves
{
return HTCAPTION;
}
case WM_CREATE :
RECT rc;
POINT point;
GetWindowRect(hWnd,&rc);
point.x = rc.left 10;
point.y = rc.top 10; // &MAKEPOINTS(
ScreenToClient(hWnd,&point);
break;
case WM_LBUTTONDOWN:
ShowMessage("ok");
break;
case WM_MOUSEMOVE:
ShowMessage("ok");
case WM_LBUTTONUP:
if (GetCapture()!= hWnd)
break;
InvalidateRect(hWnd,NULL,TRUE);
ReleaseCapture();
break;
default:
fCallDefProc=true;
break;
}
// HWND hwnd2;
// hwnd2=GetCapture();
// if (GetCapture()!= hWnd)
// ShowMessage("no");
// else
// ShowMessage("yes"); if (fCallDefProc)
lresult=DefWindowProc(hWnd,msg,wParam ,lParam);
return (lresult);
} void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (hWnd1 == NULL)
{
HINSTANCE hInstance=HInstance;
MSG msg;
WNDCLASS wClass;
wClass.style =CS_HREDRAW|CS_VREDRAW ;
// wClass.style =CS_DBLCLKS;
wClass.lpfnWndProc
=WindowProcedureWindowSenondForImageEdit;
wClass.cbClsExtra =0;
wClass.cbWndExtra =0;
wClass.hInstance =hInstance;
wClass.hIcon =LoadIcon(hInstance,IDI_APPLICATION);
wClass.hCursor =LoadCursor(NULL,IDC_ARROW);
wClass.hbrBackground =(HBRUSH)(COLOR_WINDOW 9 );
wClass.lpszMenuName =NULL;
wClass.lpszClassName ="SecondWINDOW";
if (RegisterClass(&wClass)==NULL) return;
hWnd1 =CreateWindowEx(WS_EX_TOOLWINDOW , "SecondWINDOW" ,
(LPCTSTR)"Screen",
WS_POPUP | WS_VISIBLE ,
60, 20, 500, 60 ,NULL,NULL,hInstance,NULL);
while( GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
|
lcsboy
版主 發表:87 回覆:622 積分:394 註冊:2002-06-18 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |