0
votes

I have a small project I'm working on. It has multiple dialogs so what I want to do is to have 1 main Window with multiple tabs in it. I want each tab to represent different dialog. For now I have that : Dialog with CTabCtrl opens as I expect and I have 3 tabs attached to it, when I press (for example) tab 1 it creates a new Modeless instance of my wanted PopUpDialog and it appears right where I want it. All good. But then if I move my main window , my PopUpDialog (which is borderless) stays on the same spot where he pops up at the start. Seems like the "spawn" location of my dialog is mapped to my CTabCtrl Dialog but it's not attached to it. I think I need to make it a child class or something like this . I am new to MFC and programming. I've been looking for answers for past 2 days but many links were deleted because they're too old. This is a little code example of what I'm doing:

  void CTabCtrlDialog::OnSelchangeTab(NMHDR *pNMHDR, LRESULT *pResult)
{
    CDialogIwantToPopUp *m_Page;

    m_Page = new CDialogIwantToPopUp();
    m_Page->Create(IDD_POPUP_DIALOG, m_tabTest.GetWindow(IDD_POPUP_DIALOG));

    m_Page->ShowWindow(SW_SHOW);

}

This is a function (in my dialog that contains the tab control) that is responsible for click on any tab event.

1
This seems to be a duplicate of stackoverflow.com/questions/2718855/…OldFart
You should create child dialogs for the tab controls, not popup dialogs. They have to be manually positioned inside the tab control. Don't create a dialog a each time the tab is selected. Create all child dialogs in OnInitDialog and put them in the right position. Then show/hide in response to OnSelchangeTabBarmak Shemirani

1 Answers

1
votes

I find it easiest to use a property sheet in this situation, but if that isn't appropriate for you, you need to ensure each page has the DS_CHILD style (Style: Child in the resource editor property list).

When creating the page, its parent window should be 'this' rather than what you're doing with GetWindow().