Archiv verlassen und diese Seite im Standarddesign anzeigen : mouse position in C++ ermitteln
Kann mir jemand verraten wie ich in c++ die mauspotion ermitteln kann?
x-dragon
2003-09-16, 15:34:33
Per WinApi geht das mit GetCursorPos:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Resources/Cursors/CursorReference/CursorFunctions/GetCursorPos.asp
LRESULT CALLBACK MessageHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
switch(msg){
case WM_CREATE:
break;
case WM_PAINT:
player.draw(hWnd);
mouseX=?
mouseY=?
break;
wie kann ich in diesem beispiel die koordinaten für die mausposition herausfinden
LRESULT CALLBACK MessageHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
switch(msg){
case WM_CREATE:
break;
case WM_PAINT:
POINT pt;
player.draw(hWnd);
GetCursorPos(&pt);
mouseX=pt.x;
mouseY=pt.y;
break;
und wie kann ich die position innerhalb des Fensters ermitteln?
LRESULT CALLBACK MessageHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
switch(msg){
case WM_CREATE:
break;
case WM_PAINT:
POINT pt;
player.draw(hWnd);
GetCursorPos(&pt);
if(ScreenToClient(hWnd, &pt))
{
mouseX=pt.x;
mouseY=pt.y;
}
break;
vBulletin®, Copyright ©2000-2025, Jelsoft Enterprises Ltd.