PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Windows border fix (while developing on Windows)

I mentioned this problem to Jacco some time back, but I thought I'd post it...

I noticed a while back that the click/pen position was off (in windows mode, not on the actual PDA). I fixed it by putting in lines 17 - 19 in the EasyCE.cpp file within the update() funtion.

Code:
void update( bool updscr )
{
if (updscr) updatedisplay();
#ifdef _WIN32_WCE
MSG msg;
while (PeekMessage( &msg;, 0, 0, 0, PM_NOREMOVE ) == TRUE)
{
GetMessage( &msg;, 0, 0, 0 );
TranslateMessage( &msg; );
DispatchMessage( &msg; );
}
#else
POINT p;
RECT r;
GetWindowRect( hWnd, &r; );
GetCursorPos( &p; );
#ifndef _WIN32_WCE
p.x -= 4; p.y -= 4;
#endif
mxpos = p.x - r.left;


All this does is account for the fact that windows adds 4 pixels for the window border. Once I did this, my coords were dead on.

(For a while -- and maybe still somewhat -- I thought it was just me. But I have reproduced this problem on Win98, NT, and now XP.)

Anyhow, I hope this helps anyone else that may have come across this situation.

Andre
I had noticed this as well, you fix seems to have worked :)

Jim.
You should be able to delete lines 17 and 19 for the exact same result.

Dan East
You should be using GetClientRect, followed by ClientToScreen. If you do this it will work on all versions of Windows. You should never hard-code the size of UI elements in your app.
akhromov · 07 Feb 2002, 16:19 UTC — Thanks Digby
I agree 100% with you Digby.

In fact, I just found that the coords were in fact off on NT. (Must be the different border sizes of XP versus NT, etc.)

I also looked up the GetClientRect function shortly after I posted. So the original fix was more of cludge if nothing else.

However... how about putting this into the update() code? Just my 2 cents.

Andre
akhromov · 07 Feb 2002, 16:59 UTC — Yet more drivel...
I hacked around a bit more and seemed to fix the problem on NT (will have to try it on XP and the 3800 later today).

All I did was call ScreenToClient() with the POINT that was returned for the GetCursorPos(). This gave me good coords.

Now I am wondering about the MENU_HEIGHT thing that Phantom is doing, and read on MSDN that you have to account for it. So maybe now that I fixed in on NT, it will be off on the PDA.

As, I said, just more drivel... lets hope this is the last of it.

Andre