Jump to content
  • Advertisement

Archived

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

huahsin68

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

This topic is 5358 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
Advertisement
What do you use? Pure Win32 API or MFC?

How do you open/call Dialog AAA? (DialogBox? .DoModal?)
In the event handler for the button click (WM_COMMAND or MFCs OnXXX) call the same method on Dialog BBB.

Share this post


Link to post
Share on other sites
Hi!

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

void XXDlg::OnLogin() {
SetTimer(ID_LOGIN_DIALOG,500,NULL);
}

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
One more question..

Is it every Dialog is represented by a number? Because I been notice this case for while when I create new dialog or control.

Am I right?

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;

myDlg.DoModal();

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!