Make pop-up window appear in C++ GUI

Hi guys, I've made a GUI for my program as a resource file, and have created a button to display the instructions on how to use it. However, I do not know how to make the popup for the instructions appear when I click the button.

I have created the instructions dialog box in the "dialog" folder of the resource(.rc) as well and named it "IDD_Instructions - Dialog"

The empty button code is below. The instructions dialog also has an "OK" button that should close the pop-up when pressed called "IDOK (Button Control)"

1
2
3
4
5
void CzebraDlg::OnBnClickedinstructions()
{
	
	
}


Thanks in advance for the help. I'm new to GUIs in general in C++.
Last edited on
Which library do you use to work with GUI?
Hi there, I used MFC to design the GUI. Thanks for the reply. Any idea on what I need to do?
Hi guys, any ideas on how to implement this? Thanks.
If you are using MFC, then you can use the CDialog class to load the and display the dialog.
Or if you are using the WIN APi, you have the CreateDialog function to load a modeless
dialog or the DialogBox function to load a modal dialog box.
Hi there, I made a class for the Cdialog here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class CInstructionsDlg : public CDialog //Class for instructions dialog
{
public:
	CInstructionsDlg();

// Dialog Data
	enum { IDD = IDD_Instructions };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};


along with adding the code for the button below,

1
2
3
4
void CzebraDlg::OnBnClickedInstructions()
{
	CDialog(CInstructionsDlg);
}


The program can be built and run but when I click the button, nothing happens. Did I make a mistake? Thanks in advance.
Try:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class CInstructionsDlg : public CDialog //Class for instructions dialog
{
public:
	CInstructionsDlg() :CDialog(IDD) {} //*******Updated constructor

// Dialog Data
	enum { IDD = IDD_Instructions };

	//protected: //*** Leave this out for time being
	//virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation //** Leave this out for time being
//protected:
	//DECLARE_MESSAGE_MAP()
};



1
2
3
4
5
void CzebraDlg::OnBnClickedInstructions()
{
      CInstructionsDlg  cid;  //*** Create an instance of our dialog
      cid.DoModal(); //Display Dialog box
}



By the way is IDD_Instructions the actual identifier of your dialog - or is that the title of the dialog - don't get the two things mixed up.
Last edited on
By the way are you using the MFC ClassWizard to put this altogether or are you trying to do all your class management yourself?
Hi there, thanks a lot for your help, I am able to get the pop-up to appear now. IDD_Instructions is the actual identifier under the "Dialog" folder. The title on the window just reads "Instructions".

To create the class, I did the management myself with some reference to a program my friend wrote, but did not run the pop-up. After tweaking it, it still gave me the same problems.

Thanks a lot again for your help, if I need to create other pop-ups I should know how now. :)
Topic archived. No new replies allowed.