Re: Setting focus back to original Delphi form problem

Posted by Davy on August 20, 2008

In Reply to Setting focus back to original Delphi form problem posted by BillS on July 23, 2008

: "Using Turbo Delphi:
: If I click on messagebox "ok" button, code can't enable a tedit textbox for user input. The cursor is in the desired tedit box, but user has to mouse-click on form or into text box before able to enter data.
: Seems that form and form controls are not enabled after quiting a messagedlg() (or a showmessage() for that matter).
:
: Here's a snippet of code that doesn't behave as I think it should:
: MessageDlg( 'Here is the message', mtinformation,[mbok], 0); teethstr.SetFocus;
: // sets cursor into box but doesn't allow user to enter keyboard data Exit;
:
: Workaround is to mouse-click the form, or click the box. I want the user to click "ok" to close the messagebox, then start typing at cursor in the tedit box.
:
: Please help-been trying to solve this one for a few days now...

Sorry, I can't reproduce your "focus" problem.

When I try a test application, it works in the correct way that we expect: after the message dialog closes, the original Delphi form gets the focus, and TeethStr.SetFocus sets the cursor in that TEdit, ready to type something, and that works also.

I think that your problem is not related to Turbo Delphi itself, but to some error in the code of the original form unit, from where you open the dialog box.

Related articles