Wacky EM_SETSEL Problem
It's me again! This's got to be the weirdest of the weird things I've
seen in a long time.
I've got some code that does this:
Form1.dbEdit1.SetFocus;
PostMessage(Form1.dbEdit1.Handle, EM_SETSEL, 0, -1);
(1) When returning focus to Form1 after having focus on another form.
(2) Upon arriving on a new record displayed on Form1.
Summary: It doesn't always work.
Details:
This has been working fine for over a year, but recently I added a new
form, which, unlike all the other forms, is *not* destroyed when the user
leaves. (It is an fsNormal form, unlike the other forms, which are all
fsMDIChild forms. It is hidden when the user leaves it.)
For one of around 2 dozen users, the field contents are sometimes not
selected after returning to Form1 from the fsNormal form; *but* his
cursor is in the control, and Form1 has focus. When he starts up the
system, behavior is normal, but after the first time that the EM_SETSEL
fails to work, it doesn't work again until he exits and restarts the app.
It happens whether we compile the app in D2 or D3.02. His h/w & s/w
configuration and network logins are the same as everyone else, but we
tried giving him a new pc just in case. Didn't help any.
We recorded his keystrokes but can't reproduce the problem on any other
machines. One other user did manage to reproduce the problem twice, but
doens't know what he did, and can't seem to do it again.
One last thing: This fsNormal form replaces a call to InputQuery. When we
were using InputQuery this problem didn't exist.
Ideas, anyone?