Malwider: Focus auf CEdit (Cursor setzen)
-
Moin,
ich weiß die Frage war schön öfter. Aber ich bekomme es trotsdem nicht hin.Ich möchte den Focus ändern (Also ob man in das CEdit clickt). Und dann dort alles makieren.
Mein code:
CEdit *edit = (CEdit*)GetDlgItem(IDC_MEINEDIT); if(edit != NULL && edit->GetSafeHwnd() != NULL) { edit->SetFocus(); // Returned immer NULL!!! edit->SetSel(0, -1); // nun alles Makieren } UpdateData(false);Wie so zur hölle geht das nicht. Ist doch eigendlich richtig gedacht oder?
-
Steht dein Code in OnInitDialog() ?
-
Ja, aber ich kann es nicht die Tabreinfolge verändern, da immer ein anderes Feld angesprochen werden soll.
-
Wenns so ist, dann must du FALSE zurückgeben aus der OnInitDialog();
Ich mach das immer so:
Controlvar.SetSel(0,-1); Controlvar.SetFocus();Hat mich noch nie im Stich gelassen.

-
thx - das war mein fehler "return(false);" hat gefehlt.Lesen müßte man können *gr*:
Specifies whether the application has set the input focus to one of the controls in the dialog box. If OnInitDialog returns nonzero, Windows sets the input focus to the first control in the dialog box. The application can return 0 only if it has explicitly set the input focus to one of the controls in the dialog box.
-
Dafür gibt es CDialog::GotoDlgCtrl.
Das mancht das gleich als wenn du mit der TabTaste dorthin wechseln würdest.
-
Nemesyzz schrieb:
Dafür gibt es CDialog::GotoDlgCtrl.
Gut zu wissen.
