Article

From:
To:
Adalberto Baldini
Subject:
Re: SetFocus not working well
Newsgroup:
embarcadero.public.delphi.language.delphi.win32

Re: SetFocus not working well

Adalberto Baldini wrote:

> I have a form with  :
> 
> ActiveControl = Txt_Username       (TEdit)
> procedure TLogin_dlg.FormShow(Sender: TObject);
> begin
>    txt_username.SetFocus;

You do not need to do that, just set the ActiveControl property of the
form to this edit control at designtime.

Windows does not like it when you change the focus in code at a time when another focus transition is already in progress. The focus situation is a bit fuzzy when you are in the midst of a form creation, especially when you create and show a second form during this process.
-- Peter Below (TeamB) Don't be a vampire (http://slash7.com/pages/vampires), use the newsgroup archives : http://codenewsfast.com http://groups.google.com
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Sun, 30 Jun 2024 18:03:58 UTC
Copyright © 2009-2024
HREF Tools Corp.