In the BN_CLICKED handler of a button I disable it for a while
using EnableWindow( FALSE ) and enable it again with
EnableWindow( TRUE ). I can see how the button surface changes
to the usual disabled style as expected. But if I press the button
while it's disabled I still get new BN_CLICKED messages.
The documentation says, "EnableWindow() enables or disables mouse
and keyboard input", so how can this happen?
I'd appreciate any hint. Thanks!
Ciao,
-- Eberhard
thanks for your reply! I'm sorry about having been imprecise in
my description: Sure I have to access the button in some way,
either through GetDlgItem() or a CButton variable and DDX_Control()
in DoDataExchange() -- but the error occurs either way. Thank
you anyway!
-- Eberhard
Andreas Schmidt <a...@intra-sys.de> schrieb im Beitrag <34462693...@intra-sys.de>...
Eberhard,
Is the disable/enable section during a single message processing -
i.e. is it a time when no message processing occurs in your
application? If that is the case, then I can believe that you'd get
the effect you see, because by the time your application processes the
mouse clicks you've re-enabled your button.
Dave
----
Address is altered to discourage junk mail.
Remove ".---" for the real address.
http://www.bj.co.uk
thanks for your thoughts on this issue. In fact, the disable/enable section
is located in a single message handler.
I guess I have to accept that the described behaviour is by design. I still
can get it together with the Win32 documentation of EnableWindow() that
states:
A disabled control cannot receive the keyboard focus, nor can a user
gain access to it.
I thought from this description that EnableWindow() would block the control
in such a way that Windows wouldn't send messages like WM_CLICK from this
very moment on. But in reality it seems that further message processing is
needed. If I try code like
CMyView::OnClickButtonInQuestion
{
GetDlgItem( IDC_BUTTON_IN_QUESTION )->EnableWindow( FALSE );
DoSomethingLenghtyButStillPeekAndPumpMessages();
// instead of DoSomethingLenghtyWithoutPeakAndPumpMessages()
GetDlgItem( IDC_BUTTON_IN_QUESTION )->EnableWindow( TRUE );
} ,
further button clicks in the disabled period are actually discarded.
Thanks again!
Servus,
-- Eberhard
____________________________________________________________________________
David Lowndes <dav...@mvps.org.---> wrote in
<344a62fa...@sparcone.bj.co.uk>...