VC++ 如何在顯示對話框的時候,指定焦點控件!


很簡單:

在你的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),則是根據指定的控件來設定焦點的位置.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM