SetSel() SetFocus() problems in modal dlg
How can I set the current selection to the entire word when I display a modal dialog? I have tried putting the code in the OnInitDialog(), OnShowWindow(), and also before I display the dialog but nothing works? I would also like to set the focus to that dialog but that is not working either. Here is some of the code:
HTREEITEM hTreeItem = GetSelectedItem();
CChangeOverlayDlg overlayDlg;
overlayDlg.m_OverlayName = GetItemText( hTreeItem );
// It crashes if I put it here.
overlayDlg.m_NameCtrl.SetSel( 0, -1 );
overlayDlg.SetFocus();
if ( overlayDlg.DoModal() == IDOK )
{
SetItemText( hTreeItem, overlayDlg.m_OverlayName );
}
Thanks.