很簡單:
在你的CAddDlg類的OnInitDialog函數中
加上你上面的代碼
GetDlgItem(IDC_EDIT1)->SetFocus();
最后記得return FALSE;
其實,不知道返回FALSE是啥意思!
查了說明:
Return Value
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.
翻譯一下,大概的意思是
返回值 是確定對話框在打開的時候,對話框焦點的位置.
如果返回為非零(TRUE),但指定對話框在打開的時候,焦點位於第一個控件上.
如果返回值為零(FALSE),則是根據指定的控件來設定焦點的位置.
