Article

From:
To:
All
Subject:
SetFocus not working well
Newsgroup:
embarcadero.public.delphi.language.delphi.win32

SetFocus not working well

I have a form with  :

ActiveControl = Txt_Username (TEdit) procedure TLogin_dlg.FormShow(Sender: TObject); begin    txt_username.SetFocus; Label5.Caption := ActiveControl.Name;// only for test end;
I create the form at run time from Main_frm in OnActivate Event :
Login_dlg := TLogin_dlg.Create( nil ); with Login_dlg do begin ....... ShowModal; if (ModalResult = mrOk) then begin   ..... end;

When form shows Label5.Caption shows txt_username, but TEdit doesn't have focus, cursor doesn't appear in the field, and if type anykey Btn_ok (Default) is fired. I need to click the field with the mouse to activate it.
If I reuse form in a second time it works well.
What is missing at starting time ?
Adalberto Baldini
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Sun, 30 Jun 2024 18:12:26 UTC
Copyright © 2009-2024
HREF Tools Corp.