Formkoordinaten ermitteln



  • hi,

    mit GetCursorPos hole ich mir die bildschirm koordinaten .. wie konvertiere ich das, damit es zur form passt? also ich möchte nur im clientbereich die koordinaten haben



  • War da nicht mal was mit DPtoLP? 😕
    Ich bin da aber noch nicht so firm...



  • @user123,

    ich würde das ganz einfach berechnen.

    RECT clientRect;
    POINT cursorPos;
    POINT resultPos;
    
    GetCursorPos( &cursorPos );
    GetClientRect( hWnd, &clientRect );
    
    resultPos.x = cursorPos.x - clientRect.left;
    resultPos.y = cursorPos.y - clientRect.top;
    

    Das ganze kann man bestimmt noch eleganter schreiben,
    aber als Erklärung sollte es genügen.

    Bye Peter.



  • danke an euch, hab was gefunden

    void ScreenToClient(
    LPPOINT lpPoint
    ) const;

    void ScreenToClient(
    LPRECT lpRect
    ) const;

    The ScreenToClient member function replaces the screen coordinates given in lpPoint or lpRect with client coordinates. The new coordinates are relative to the upper-left corner of the CWnd client area.


Anmelden zum Antworten