在InitDialog中设置焦点不起作用 SETFOCUS

来源:互联网 发布:portal软件 编辑:程序博客网 时间:2024/05/01 03:19

一、在WM_SHOWWINDOW中试试 
void   CTestdlg3Dlg::OnShowWindow(BOOL   bShow,   UINT   nStatus)   

CDialog::OnShowWindow(bShow,   nStatus); 

CEdit*   pedit=(CEdit*)GetDlgItem(IDC_EDIT); 
pedit-> SetFocus(); 

 

二、在InitDialog中要设置某个控件的焦点,必须返回FALSE 
BOOL   CODBCLiborDlg::OnInitDialog() 

          CDialog::OnInitDialog(); 
          //…… 
          
          CButton*   pButton   =   static_cast <CButton*> (GetDlgItem(IDC_BTN)); 
          ASSERT(pButton   !=   NULL); 
          pButton-> SetFocus(); 

          return   FALSE;     
}

 

三、在窗口编辑中,按CTRL+D来调整顺序

原创粉丝点击