Hi all.

When I do this:

Win32::GUI::Dialog()

I receive all my events like WM_LBUTTONDOWN (-onMouseDown) once, as
should happen.

When I do this:

while(1) {
        Win32::GUI::DoEvents()
        print "Loop!\n";
}

I get endless calls to my event handler so long as the mouse button is
down. I have NO idea why. Must be some kind of windows internal thing.

Additionally, since the code for DoEvents() and Dialog() is practically
identical except that DoEvents uses PeekMessage and Dialog uses
GetMessage, I copied both into seperate files and took a look at them in
WinMerge. Interesting. Dialog does ENTER; SAVETMPS; before doing
GetMessage and FREETMPS; LEAVE; at the end of it's while() loop.
DoEvents() doesn't do this. Also, DoEvents has the line "acc =
perlud->hAcc;", and Dialog() DOESNT have that. Dialog() does a
comparison on acc (acc != NULL) in the next few lines just like DoEvents
does, but this comparison will always yield false in Dialog().

So. I don't have a compiler here but this is weird. Surely these
functions should be identical but for the change from GetMessage to
PeekMessage. Moreover, if these functions should be identical then why
write the same code for both when a simple function that does either
PeekMessage or GetMessage depending on an argument would remove a lot of
redundant code, for example the new function checkEvents(hwnd,
peekmessage) would do the current Dialog() code with PeekMessage if
peekmessage was set to 1, otherwise it'd do GetMessage, and the Dialog()
and DoEvents() methods could be truncated to:

DWORD
Dialog(hwnd=NULL)
        HWND hwnd
CODE:
        RETVAL = checkEvents(hwnd,0);
OUTPUT:
        RETVAL

DWORD
DoEvents(hwnd=NULL)
        HWND hwnd
CODE:
        RETVAL = checkEvents(hwnd,1);
OUTPUT:
        RETVAL



Steve

Reply via email to