PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : mouse position in C++ ermitteln


blax
2003-09-16, 14:59:54
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

blax
2003-09-16, 15:43:35
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

Gast
2003-09-16, 15:52:03
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;

blax
2003-09-19, 19:38:46
und wie kann ich die position innerhalb des Fensters ermitteln?

Xmas
2003-09-23, 00:15:30
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;