tutorials.de Buch-Aktion 05/2012
ERLEDIGT
JA
ANTWORTEN
2
ZUGRIFFE
671
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    Avatar von jokey2
    jokey2 jokey2 ist offline Mitglied Smaragd
    Registriert seit
    Nov 2004
    Beiträge
    1.235
    In einer Anwendung mit einem TreeView habe ich ein Kontextmenü implementiert, das mit der rechten Maustaste geöffnet wird:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    void CLeftView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
         {
            //Mauskoordinaten ermitteln
            dwPos = GetMessagePos();
            ptSCR.x = LOWORD (dwPos);
            ptSCR.y = HIWORD (dwPos);
            ptLV = ptSCR;
            ScreenToClient(&ptLV);
         
            //geklicktes Item ermitteln
            Item.hItem = Tree.HitTest(ptLV, &uFlags );
         ....
     }
    Das klappt auch soweit, zumindest wenn ich nur einen Bildschirm habe. Wenn allerdings 2 Bildschirme da sind, wie bei vielen unserer Arbeitsplätze, funktioniert es nicht mehr. ptLV.x ist immer größer 65535, wenn das Applikationsfenster im Bildschirm 2 ist.
    Gibt es irgendwo Infos darüber, wie sich das ScreenToClient(..) bei 2 Bildschirmen verhält? Kann ich davon ausgehen, daß ich immer nur das Low-word der X-Koordinate brauche?
    Ich würde mich freuen, wenn mir da einer was sagen könnte, was mir weiterhilft.

    Grüße an alle,
    jokey2
     

  2. #2
    Avatar von Endurion
    Endurion Endurion ist offline Mitglied Diamant
    Registriert seit
    Apr 2004
    Beiträge
    2.151
    Bei GetMessagePos steht in der MSDN Folgendes unter Remarks:

    As noted above, the x-coordinate is in the low-order int of the return value; the y-coordinate is in the high-order int (both represent signed values because they can take negative values on systems with multiple monitors). If the return value is assigned to a variable, you can use the MAKEPOINTS macro to obtain a POINTS structure from the return value. You can also use the GET_X_LPARAM or GET_Y_LPARAM macro to extract the x- or y-coordinate.

    Important Do not use the LOWORD or HIWORD macros to extract the x- and y- coordinates of the cursor position because these macros return incorrect results on systems with multiple monitors. Systems with multiple monitor systems can have negative x- and y- coordinates, and LOWORD and HIWORD treat the coordinates as unsigned quantities.
     

  3. #3
    Avatar von jokey2
    jokey2 jokey2 ist offline Mitglied Smaragd
    Registriert seit
    Nov 2004
    Beiträge
    1.235
    Danke für den Tip! Mit GET_X_LPARAM und GET_Y_LPARAM klappt es auch mit 2 Bildschirmen in jeglicher Anordnung.
     

Ähnliche Themen

  1. Led's an Bildschirmen und Router usw.
    Von yahuu33 im Forum Cinema 4D
    Antworten: 3
    Letzter Beitrag: 27.03.09, 10:18
  2. Problem: Windows mit 2 Bildschirmen.
    Von josDesign im Forum Microsoft Windows
    Antworten: 2
    Letzter Beitrag: 23.08.07, 14:27
  3. Desktop auf 2 Bildschirmen
    Von Kurt Cobain im Forum Microsoft Windows
    Antworten: 7
    Letzter Beitrag: 26.10.05, 00:31
  4. Bildschirmkoordinaten und Screenshot?
    Von Math55 im Forum Swing, Java2D/3D, SWT, JFace
    Antworten: 1
    Letzter Beitrag: 25.07.05, 04:06
  5. Antworten: 3
    Letzter Beitrag: 22.03.04, 23:53