From: Johan L. <jo...@ba...> - 2002-10-21 22:50:03
|
At 22:21 2002-10-21 +0200, Johan Lindstrom wrote: >>Using 0.0.558, I call Win32::GUI::DoEvents() manually from a main loop . >>I have a popup-menu on a NotifyIcon, nothing else. >> >>This is the weird thing. When I select something in the menu, the event >>handler gets called twice. > >Ok. The same thing goes for cursor movement events within e.g. a RichEdit >or a TextField control. Pressing the right arrow to move the cursor one >step will cause it to Ok. This is as kluge if I ever saw one. But it works (I guess). This is my (simplified) idle sub, which I call as often as possible: use constant WM_APP => 0x8000; #From winuser.h (Visual Studio) use constant WM_EXITLOOP => WM_APP + 1; #From GUI.xs sub idle { my ($win) = tglApp($tglWindow); if($win->PeekMessage()) { $win->PostMessage(WM_EXITLOOP, 0, 0) for (0..1); Win32::GUI::Dialog(); } Win32::GUI::DoEvents() while($win->PeekMessage()); return(1); } So it works like this. I want to use the DoEvents for my tray icon. But I need the Dialog() call for the window, otherwise some keyboard events are doubled. So if there are messages waiting on the window, I post two WM_EXITLOOP (one isn't enough, maybe I'll post more just to be sure) to the end of the message queue. That way I can do the Dialog() call and still get back control. Then I empty the event queue with DoEvents() so it's clear for the next run, and the tray icon gets processed as well. (Hmmm... maybe I could do the same with the tray icon, that way the menu events may work as indented as well...) There's probably a good reason why I shouldn't do any of this. /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos jo...@ba... Latest bookmark: "XEmacs XEmacs and Supporting Libraries and Prog..." http://xemacs.org/Download/win32/ dmoz: /Computers/Open_Source/Software/Editors/ 98 |