下面這個例子是獲取螢幕的座標:
#include#includelresult callback windowproc(
hwnd hwnd, // handle to window
uint umsg, // message identifier
wparam wparam, // first message parameter
lparam lparam // second message parameter
);
int winapi winmain(
hinstance hinstance, // handle to current instance
hinstance hprevinstance, // handle to previous instance
lpstr lpcmdline, // command line
int ncmdshow // show state
) hwnd=createwindow(
text("this is title"), // window name
cw_usedefault, // horizontal position of window
cw_usedefault, // vertical position of window
cw_usedefault, // window width
cw_usedefault, // window height
null, // handle to parent or owner window
null, // menu handle or child identifier
null // window-creation data
);
showwindow(hwnd,ncmdshow);
updatewindow(hwnd);
while(getmessage(&msg,null,0,0))
return msg.wparam;
} lresult callback windowproc(
hwnd hwnd, // handle to window
uint umsg, // message identifier
wparam wparam, // first message parameter
lparam lparam // second message parameter
)
return defwindowproc(hwnd,umsg,wparam,lparam);
}
可以把螢幕座標轉化為客戶區座標:
#include#includelresult callback windowproc(
hwnd hwnd, // handle to window
uint umsg, // message identifier
wparam wparam, // first message parameter
lparam lparam // second message parameter
);
int winapi winmain(
hinstance hinstance, // handle to current instance
hinstance hprevinstance, // handle to previous instance
lpstr lpcmdline, // command line
int ncmdshow // show state
) hwnd=createwindow(
text("this is title"), // window name
cw_usedefault, // horizontal position of window
cw_usedefault, // vertical position of window
cw_usedefault, // window width
cw_usedefault, // window height
null, // handle to parent or owner window
null, // menu handle or child identifier
null // window-creation data
);
showwindow(hwnd,ncmdshow);
updatewindow(hwnd);
while(getmessage(&msg,null,0,0))
return msg.wparam;
} lresult callback windowproc(
hwnd hwnd, // handle to window
uint umsg, // message identifier
wparam wparam, // first message parameter
lparam lparam // second message parameter
)
return defwindowproc(hwnd,umsg,wparam,lparam);
}
c 獲取滑鼠座標
很多時候我們需要用到滑鼠在相對於窗體上的座標,或者相對於螢幕的座標,這裡就把我的經驗記錄下。用control.mouseposition獲得當前滑鼠的座標currentpoint,使用control.pointtoclient方法,前面獲得的currentpoint作為其引數,返回的point型別的...
flex學習 獲取滑鼠座標
得到滑鼠位置 private function getlocation event mouseevent void trace localx event.localx localy event.localy 相對於元件的座標,如果在button上,則相對於button trace stagex ev...
VC 獲取滑鼠點座標
onlbuttondown 傳入的point座標為客戶區座標,而輸出矩形為窗體座標,point縱座標需要加上 標題欄高度 26 和對話方塊高度 3 point橫座標需要加上 對話方塊寬度 3 int captionheight getsystemmetrics sm cycaption 標題欄高度 ...