1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Win32' started by jacks_sparrow, May 11, 2010.

  1. jacks_sparrow

    jacks_sparrow New Member

    Joined:
    May 11, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    You have to manually move the focus from dialog to other one.
     
  3. jacks_sparrow

    jacks_sparrow New Member

    Joined:
    May 11, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hello Shabbir,

    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?
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    When you have 2 different set of dialogs the tab order can be jumbled for various reasons and so it is best to be done manually
     
  5. jacks_sparrow

    jacks_sparrow New Member

    Joined:
    May 11, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Can you help me to go into that various reasons, please give any reference, doc, link to this.
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    One of them is your child dialog does not have the Tab order correctly set to and other could be that tab order of your button and your next child window is not in order.
     

Share This Page