CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: SetSel() SetFocus() problems in modal dlg

  1. #1
    Join Date
    Oct 2001

    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 );

    if ( overlayDlg.DoModal() == IDOK )
    SetItemText( hTreeItem, overlayDlg.m_OverlayName );


  2. #2
    Join Date
    Nov 1999
    Dresden / Germoney
    Set focus to the edit in OnInitDialog, but return FALSE (instead of TRUE, which is "the default)

  3. #3
    Join Date
    Oct 2001
    Thanks. That worked. Is there a way to highlight the current selection when using modal dialogs? Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)