On approximately 12/9/2003 2:59 AM, came the following characters from
the keyboard of Stephen Pick:

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.

Certain Windows messages are "queued and combined" if you are not looking, but the more often you look, the more often you get them.... I could say if MouseDown is one of those, off hand.

I have noticed that a difference between Dialog() and DoEvents() is that if used to process a dialog box containing a text box, that the former responds normally, but the latter generally doubles the characters received by the text box. One difference in my situation is that I was calling DoEvents() from an event, and that might cause some sort of reentrancy problem, but I couldn't understand what it would be if it is such. I gave up and restructured my code to use Dialog() only.

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.

This is because Dialog is "long-running" and needs to be sure to do Perl temporary variable management, and DoEvents returns to Perl more often, so can let Perl do the temporary variable management. I think.

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().

I think that was one of the lines I "fixed" in making accelerator keys work. If not, it should have been. What version of source are you looking at?

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:

Well, the exit condition is different too, not just the call to GetMessage vs PeekMessage. But that also could be based on the "argument". I agree there is much redundant code there, also see DoModal.


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


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Perl-Win32-GUI-Hackers mailing list
Perl-Win32-GUI-Hackers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-hackers



--
Glenn -- http://nevcal.com/
===========================
Like almost everyone, I receive a lot of spam every day, much of it
offering to help me get out of debt or get rich quick.  It's ridiculous.
-- Bill Gates

And here is why it is ridiculous:
The division that includes Windows posted an operating profit of $2.26 billion on revenue of $2.81 billion. --from Reuters via http://biz.yahoo.com/rc/031113/tech_microsoft_msn_1.html

So that's profit of over 400% of investment... with a bit more investment in Windows technology, particularly in the area of reliability, the profit percentage might go down, but so might the bugs and security problems? Seems like it would be a reasonable tradeoff. WalMart earnings are 3.4% of investment.


Reply via email to