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

Hybrid View

  1. #1
    Join Date
    Oct 2001
    Posts
    30

    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.

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

  3. #3
    Join Date
    Oct 2001
    Posts
    30
    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
  •  





Click Here to Expand Forum to Full Width

Featured