CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2008
    Posts
    9

    Question Cannot move the focus from control of child dialog to control of parent dialog

    I have two MFC applications, one application acts as a parent which creates the dialog (as a child) dynamically using second application. Second application is the MFC extension dll. I have to move focus in between these two dialogs (parent and child) using tab. For that purpose I used the SetWindowPos() API.


    Following is the code in the child dialog.

    m_Btn_CheckOne.SetWindowPos(NULL, 20, 20, 60, 25, 0);
    m_Btn_CheckTwo.SetWindowPos(&m_Btn_CheckOne, 20, 80, 60, 25, 0);
    m_Btn_CheckThree.SetWindowPos(&m_Btn_CheckTwo, 20, 140, 60, 25, 0);
    ((CmainDlg*)GetParent())->m_Btn_FromMainDlg.SetWindowPos(&m_Btn_CheckThree , 20, 140, 60, 25, 0);


    m_Btn_FromMainDlg is the button from the main dialog. And I expect that once I press tab on the button m_Btn_CheckThree focus should get shifted to the m_Btn_FromMainDlg button in the main dialog.


    But which is not occurring Focus is get circulated only in child dialog.
    Can anybody help me out.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Cannot move the focus from control of child dialog to control of parent dialog

    It's not very clear what you are doing here, but are you sure that GetParent is returning the window you expect it to? Your casting it without checking it. I'm not positive, but I don't think MFC extension dll's work like that. Also, I think tab stop focusing of controls is handled like an accelerator. You may have to intercept it in a PreTranslateMessage() handler.

  3. #3
    Join Date
    Dec 2008
    Posts
    9

    Re: Cannot move the focus from control of child dialog to control of parent dialog

    Thanks for reply..

    I have tried it with GetAncestor() method (with GA_PARENT flag) instead of GetParent() and its not fruitful.

    ((CmainDlg*)GetAncestor(GA_PARENT))->m_Btn_FromMainDlg.SetWindowPos(&m_Btn_CheckThree , 20, 140, 60, 25, 0);

    Also

    I have the another application with same scenario. In that application child dialog is from the same application instead of from another MFC Extension DLL application.

    Above code is working fine in above mentioned application. So I wondered how is it? If it is working here, so why it is not in there mentioned in my query.

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