CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 1999
    Posts
    306

    GetFocus() don't behave properly?!

    I have a dialog with a combobox on it. And in PreTranslateMessage() I want to check if the focus is on the combobox. So I do the following:

    void CMyDialog::PreTranslateMessage(MSG* pMsg)
    {
    int ret = CDialog::PreTranslateMessage();

    if(pMsg->message==WM_KEYUP)
    if(GetDlgItem(IDC_COMBO) == GetFocus())
    {
    // do something
    }

    return ret;
    }

    the second if always return FALSE. Where do I fail?


  2. #2
    Join Date
    May 1999
    Posts
    48

    Re: GetFocus() don't behave properly?!

    The focus is received by inside edit of combbox, not combo.
    Sincerely, Mihai



  3. #3
    Join Date
    Apr 1999
    Posts
    306

    Re: GetFocus() don't behave properly?!

    So how should I write it then?


  4. #4
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: GetFocus() don't behave properly?!

    Try this:


    void CMyDialog::PreTranslateMessage(MSG* pMsg)
    {
    const int ret = CDialog::PreTranslateMessage();

    if (pMsg->message==WM_KEYUP)
    {
    if (GetDlgItem(IDC_COMBO)->GetWindow(GW_CHILD) == CWnd::GetFocus())
    {
    // do something
    }
    }

    return ret;
    }





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