和滑鼠相關的三個屬於:click,double-click,drag
滑鼠訊息和鍵盤訊息不同:只要滑鼠跨越某個視窗,或者在某個視窗中按鍵,訊息。
客戶去滑鼠訊息
wm_mousemove
wm_[l,m,r] buttondown
wm_[l,m,r] buttonup
wm_[l,m,r] buttondblclk
對於這些訊息,lparam的低位元組為x座標,高位元組為y座標。
wparam只是滑鼠按鍵以及shift和ctr1按鍵的狀態(這個和鍵盤訊息相似)。
要測試滑鼠按鈕是否按下:mk_lbutton,mk_mbutton,mk_rbutton,mk_shift,mk_control.
非客戶區滑鼠訊息:
wm_ncmous emove
wm_nclbuttondown.
wm_nclbuttonup
wm_nclbuttondblclk
1 #include2 #include3 #include4 #include5view code6lresult callback windproc(hwnd hwnd, uint message, wparam wparam, lparam lparam);78
int winmain(hinstance hinst, hinstance tmp, lpstr szcmd, int
nshow)936
return0;
37}3839
4041
lresult callback windproc(hwnd hwnd, uint message, wparam wparam, lparam lparam)
4260 endpaint(hwnd, &pt);
61return0;
62case
wm_char:
63return0;
64case
wm_lbuttonup:
65 i = 0;66
invalidaterect(hwnd, null, true);
67return0;
68case
wm_lbuttondown:
69invalidaterect(hwnd, null, true);
70if (loword(lparam)>10 && loword(lparam)<100 && hiword(lparam)>10 && hiword(lparam)<100)71
74return0;
75case
wm_mousemove:
76 hdc =getdc(hwnd);
77if (wparam&mk_lbutton)
7881
releasedc(hwnd, hdc);
82return0;
83case
wm_destroy:
84 postquitmessage(0
);85
return0;
86default:87
break;88
}8990return
defwindowproc(hwnd, message, wparam, lparam);
91 }
windows主要滑鼠訊息
windows主要滑鼠訊息 wm lbuttondown 滑鼠停留在客戶區,同時滑鼠左鍵按下 wm lbuttonup 滑鼠左鍵釋放 wm rbuttondown 滑鼠停留在客戶區,郵件按下 wm rbuttonuo 右鍵釋放 wm mbuttondown 滑鼠在客戶區,中鍵按下 wm mbutto...
windows主要滑鼠訊息
windows主要滑鼠訊息 wm lbuttondown 滑鼠停留在客戶區,同時滑鼠左鍵按下 wm lbuttonup 滑鼠左鍵釋放 wm rbuttondown 滑鼠停留在客戶區,郵件按下 wm rbuttonuo 右鍵釋放 wm mbuttondown 滑鼠在客戶區,中鍵按下 wm mbutto...
windows遊戲程式設計滑鼠
常用滑鼠訊息 wm mousemove 滑鼠移動位置 wm lbuttondown 滑鼠左鍵按下 wm lbuttonup 滑鼠左鍵彈起 wm lbuttondblclk 滑鼠左鍵雙擊 wm rbuttondown 滑鼠右鍵按下 wm rbuttonup 滑鼠右鍵彈起 wm rbuttondblcl...