简体   繁体   中英

How to make two dialog boxes into one combined Dialog box using MFC?

Currently I have two dialog box templates in my resources.

I want to dynamically add the content on the right template to the dialog box on the left template. How would I do this?

一只忙碌的猫

Output Should look like this: 一只忙碌的猫

Also, I'm using MFC c++. I'm very new to this and I would really appreciate any help!

Here is what I tried to do, but only the main dialog box would show:

MainDialogBox *mainDlg = new MainDialogBox();
subDialogBox *subDlg = new subDialogBox(mainDlg);

Change the child dialog template by removing its titlebar and border styles. That will make it blend in and look like a part of the parent dialog.

Then you create the child dialog as a modeless dialog whose parent window is the parent dialog. (Use CDialog::Create to create a modeless dialog.) If you are already doing that and the second dialog does not show maybe you did not set the 'Visible' style.

When you create the parent dialog give it the style WS_EX_CONTROLPARENT. This will help with keyboard navigation between the parent and child.

Finally, you need to position the child dialog where you want it on the parent dialog. The parent can pass in an x,y point or a rectangle to the dialog constructor. Then the child (in OnInitDiialog) can position itself by calling SetWindowPos.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM