在CDialog::OnInitDialog设置DEFAULT-BUTTON的注意事项

如果你的Dialog是在资源编辑器里面创建的,那么你首先要去资源编辑器把对应的Button的Default Button选项设置为True

 

另外,如果你使用GotoDlgCtrl,那么记得OnInitDialog必须返回FALSE,详见OnInitDialog的文档:

 If OnInitDialogreturns nonzero, Windows sets the input focus to the default location, the first control in the dialog box. 

 

参考:https://msdn.microsoft.com/en-us/library/fwz35s59.aspx

 

另外,不要使用SetFocus,见:http://blogs.msdn.com/b/oldnewthing/archive/2004/08/02/205624.aspx

posted @ 2015-10-08 16:33  rldts  阅读(382)  评论(0编辑  收藏  举报