Multi-monitor problem with CRect and CPoint
Posted on 2007-09-28
I've just been alerted to some wierd behaviour (bug in op system / MFC code ?)
I have a user that has a two monitor system (in Europe) and, for some reason, has the primary monitor defined as the monitor on the right and the secondary monitor is on the left. So the system thinks the top left of the primary monitor is 0, 0
This, of course, means the co-ordinates on the left hand monitor are 'strange'.
I am performing a hit test on a control drawn into the NC area of an edit box. It isn't responding to the mouse. basically return rectButton.PtInRect(ptTest);
rectButton is a CRect and ptTest is a CPoint.
The value in ptTest has an x-co-ordinate of 64786 and in the rectButton the l, r is -761, -744
So the PtInRect call is failing - despite the mouse being in the rectangle the return is false.
Is there a flag/function to make it compare the signed/unsigned values correctly or do I have to code some sort of hack?