Einzelnen Beitrag anzeigen

Fuchtel

Registriert seit: 9. Nov 2005
Ort: Bamberg
53 Beiträge
 
Delphi 2005 Personal
 
#3

AW: Von TEdit den Focus wechseln, wenn die Eingabe noch aktiv ist.

  Alt 22. Jul 2011, 06:57
Danke sx2008 für die Hilfe.

Hat aber erstmal so nichts gebracht:

Sobald vor WM_SetFocus eine normale Msg-Box auf und wieder zugemacht wurde funzte es.

Lasse ich den Namen und ClassenNamen anzeigen, wie von dier zum Test vorgeschlagen, ist MsgBox leer.
Setze ich aber darauf einen Breakpoint, und lasse sie dann mit [F9] anzeigen ist der korrekte Inhalt darin. Seltsam !?!

Auf jedenfall habe ich doch noch (nach weiterem langen Probieren) eine Lösung gefunden:

(Frag mich aber nicht warum das Funzt!):

Delphi-Quellcode:

  TButton(lOBJ.Items[iY]).Perform(WM_SetFocus,scr_Main.Handle,0);
  SendMessage(Handle, WM_NEXTDLGCTL, TButton(lOBJ.Items[iY]).Handle, 1);
Die entscheidende Info:

Zitat:

Do not call SetFocus in a dialog window, except in WM_INITDIALOG
Note: Do not call SetFocus to change a control's focus in a dialog window, except when handling the WM_INITDIALOG message.

To explicitly set the focus to a dialog's control call SendMessage(hDialog, WM_NEXTDLGCTL, (WPARAM)hwndCtrl, TRUE). The WM_NEXTDLGCTL message notifies the dialog manager that the focus has changed.

The exception is the initial WM_INITDIALOG message. When you receive WM_INITIDIALOG call SetFocus on the desired control's hWnd. You must return FALSE to notify the dialog manager that you set the initial focus.

When handling other dialog messages if you use SetFocus (and not WM_NEXTDLGCTL) it prevents the dialog manager from updating its internal bookkeeping. For example, it might cause the dialog manager to display the wrong default pushbutton or fail to select the text of an edit control. For details see Raymond Chen's book The Old New Thing, page 227, "How to set focus in a dialog box." (Or see his blog.)
Quelle: http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

Trotzdem Danke,

Fuchtel
  Mit Zitat antworten Zitat