How to set focus to a control in the dialog startup
Setting focus to a dialog control is more than just call SetFocus.
Normally, the focus is set to a control which was higher in z-order. But we can set focus in two ways.
- Call SetFocus() function to desired control in OnInitDialog and return FALSE.
- Call ::PostMessage( this->m_hWnd, WM_NEXTDLGCTL, (WPARAM)( GetDlgItem( IDC_BUTTON1 )->m_hWnd ), TRUE ); in OnInitDialog() and return TRUE. Don’t call SendMessage instead of PostMessage.
-
Archives
- September 2008 (1)
- August 2008 (4)
- July 2008 (5)
-
Categories
-
RSS
Entries RSS
Comments RSS