Hi,
So it seems to be the case that DoEvents loops and keyboard events don't
do to well together... producing double characters while typing...
almost all of the time. DoEvents uses PeekMessage to obtain its events,
of course, whereas Dialog uses GetMessage.
I don't recall this problem occurring on Win32::GUI 0.0.558 -- can
anyone confirm that it did? If not, it seems to be related to
Win32::GUI 0.0.665, perhaps. But I can't see any significant code
differences in the DoEvents loop that would affect it in this manner.
Then I get to wondering... the program in which I use DoEvents was
written a couple years ago, and maybe I was using WinNT 4.0 SP3 then,
and my users were on Win98. Now I'm using Win2K SP3, and my users have
upgraded to WinXP, and were both able to produce the problem. So maybe
it is a bug introduced in Win2K and not yet fixed in XP either, in the
PeekMessage code?
Thinking along those lines, and reading about how Get/PeekMessage worked
back in the days they were last documented, which seems to be around the
transition from Win3.1 to Win95, it sounds as if Get/PeekMessage uses
some sort of timestamp based technique for determining the validity of
messages. So maybe with fast processors these days, we can execute a
whole loop of code, and get back before the clock ticks? Even, perhaps,
the fairly high resolution one that surely must be used for
Get/PeekMessage? So I added a call to sleep in the DoEvents code,
conditional on it being a WM_CHAR, WM_KEYDOWN, or WM_KEYUP message, and
was able to affect the percentage of keys that were duplicated in normal
typing. So perhaps it is somewhat timing related.
But if it were a Win2K/XP problem, you'd think it would show up in other
programs that use PeekMessage loops. Anyone ever hear about that?
Anyway, I never saw the effect when I was originally creating this
program, so it seems that the problem has been created via a change to
Win32::GUI or Windows itself. I've now read lots of Windows
documentation and added a fair bit of extra debugging printfs to the
Win32::GUI code, without finding anything obvious that is done wrong in
Win32::GUI's DoEvents loop (regarding character duplication... in other
emails I've revealed lots of missing code for Accelerator Keys), so I'm
kind of at the end of my ideas regarding this.
I did all the above testing on Win2K SP3, Perl 5.8.1 build 802,
Win32::GUI 0.0.665, Althon 950 MHz. This morning I tested my same
script on Win98 (1st edition), Perl 5.6.1 build 633, Win32::GUI 0.0.665,
Pentium II 233 MHz. Same results. These are the only two machines I
can easily test on.
Anyone have some other ideas of things to try?
--
Glenn
=====
Not everything that is counted counts,
and not everything that counts can be counted.
-- A. Einstein