This topic is now archived and is closed to further replies.

How to call a dialog in VC++ from another dialog?

This topic is 5110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! Nice to meet you.. I was using VC++.. I have a dialog, lets say IDD_DIALOG_A. Then this dialog I have a button which will trigger another dialog to be shown up. That dialog''s ID is IDD_DIALOG_B. So is there any function or API that can help me in doing this? Before this, I saw an sample.. This sample very tricky.. AAA.SetDlgPtr(this,BBB); IDD_DIALOG_A is represented by AAA. IDD_DIALOG_B is represented by BBB. My problem is I don know where this programmer declare or define BBB? So please help me.. Thank You @!

Share this post

Link to post
Share on other sites

I found another example here... It was in the same project.. It is a MFC project.

void XXDlg::OnLogin() {

This function was called up by using event handle: WM_COMMAND and this function work correctly (shows up the Login Dialog).

My problem is I have search through the whole project to find out which dialog represented by ID_LOGIN_DIALOG. There should be something like this:

ID_LOGIN_DIALOG = Login Dialog;

But I couldn''t this, what I get is:

#define ID_LOGIN_DIALOG 103

So, do you have any recommandation on this? How can I know Login Dialog is represented by ID_LOGIN_DIALOG?

Thank You @!

Share this post

Link to post
Share on other sites
Everytime you create a dialog in the resource editor windows will assign it a number (usually IDD_DIALOGxxx).

If you are using Win32 API directly this ID/number you need to use with createdialog.

If you are using MFC you need to create a dialog class for the dialog you edited (simply double click on the dialog and the wizard will help you create a code class for the dialog).

Suppose you have IDD_DIALOG_A and IDD_DIALOG_B. After creating a code class for both you have CDialogA for IDD_DIALOG_A and CDialogB for IDD_DIALOG_B.

Then you just call do:

CDialogA myDlg;


Share this post

Link to post
Share on other sites