Bildschirmkoordinaten mit 2 Bildschirmen

jokey2

Erfahrenes Mitglied
In einer Anwendung mit einem TreeView habe ich ein Kontextmenü implementiert, das mit der rechten Maustaste geöffnet wird:
Code:
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
 
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.
 
Danke für den Tip! Mit GET_X_LPARAM und GET_Y_LPARAM klappt es auch mit 2 Bildschirmen in jeglicher Anordnung.
 
Zurück