Board index » delphi » Extra OnEnter Event

Extra OnEnter Event

I am using Delphi 3 (with some third party components) and Windows 95
(with 32 bit FAT).

I have a method that opens a dialog box.  It is called from seven places.
 When the user is done using that dialog box, he clicks a close button.  
That starts execution of code that sends the focus back to where it was
when the dialog box was opened.  All works fine for six of the calls.  
For the seventh, the focus goes to the wrong control.  I have stepped
thru the code.  The difference:  the event handler for an OnEnter event
is being executed during that call and not in the other six.  That causes
the focus to go to the wrong component.  I have found nothing to trigger
that OnEnter event.  Anyone have any ideas why it is triggered and how I
can stop it?

Thanks for any help.

                                      Maurie

 

Re:Extra OnEnter Event


Quote
> I have a method that opens a dialog box.  It is called from seven places.
>  When the user is done using that dialog box, he clicks a close button.  
> That starts execution of code that sends the focus back to where it was
> when the dialog box was opened.  All works fine for six of the calls.  
> For the seventh, the focus goes to the wrong control.  I have stepped
> thru the code.  The difference:  the event handler for an OnEnter event
> is being executed during that call and not in the other six.  That causes
> the focus to go to the wrong component.  I have found nothing to trigger
> that OnEnter event.  Anyone have any ideas why it is triggered and how I
> can stop it?

Maurie,

if you set focus to a control via SetFocus, SelectNext or by sending a
WM_NEXTDLGCTL message to the form the OnEnter event of the target control
will fire. To prevent that you have to disconnect the event handler
(assign Nil to the event) before you set the focus and reconnect it
afterwards.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Re:Extra OnEnter Event


This is a test to verify that we are able to post to this News Group.  I
appologize for the inconvience
Quote
Peter Below (TeamB) wrote:
> > I have a method that opens a dialog box.  It is called from seven places.
> >  When the user is done using that dialog box, he clicks a close button.
> > That starts execution of code that sends the focus back to where it was
> > when the dialog box was opened.  All works fine for six of the calls.
> > For the seventh, the focus goes to the wrong control.  I have stepped
> > thru the code.  The difference:  the event handler for an OnEnter event
> > is being executed during that call and not in the other six.  That causes
> > the focus to go to the wrong component.  I have found nothing to trigger
> > that OnEnter event.  Anyone have any ideas why it is triggered and how I
> > can stop it?

> Maurie,

> if you set focus to a control via SetFocus, SelectNext or by sending a
> WM_NEXTDLGCTL message to the form the OnEnter event of the target control
> will fire. To prevent that you have to disconnect the event handler
> (assign Nil to the event) before you set the focus and reconnect it
> afterwards.

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitely requested!

Other Threads