Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I made a button named Brightness on my main dialogue box. When any one click on it, it should display another dialogue box named Brightness.

For this, I right click on my project in the solution explorer->add->resource
From the Add Resource dialog box, double-click on Dialog
Change its ID to IDD_DLG_BRIGHTNESS and set its Caption to BRIGHTNESS.

Now what should I do next? One thing I have also done that I right click on BRIGHTNESS dialogue-add class and specify class name as CBrightnessDlg. Waiting for your reply.
Posted
Updated 9-Jun-10 22:58pm
v2

Add a message handler for the BM_CLICK notification from your button (you can do it by double-clicking the button on the dialog-editor), then inside the message handler add code to show your dialog, like this:

C++
CBrightnessDlg dlg(this);
if (dlg.DoModal() == IDOK)
{
   // Do something
}
 
Share this answer
 
It is easier to right-click the project and chose Add -> Class, and derive from CDialog. That way you will get the class skeleton and the dialog resource directly.

In your main dialogs event handler for your button, create an instance of your dialog and show it.

// In message map of main dlg
    ON_BN_CLICKED(IDC_BRIGHTNESS_BUTTON, OnClickBrightnessButton)

void CMainDlg::OnClickBrightnessButton()
{
    CBrightnessDlg brightnessDlg;

    // Maybe set data in your dialog here:
    // brightnessDlg.SetBrightness(m_brightness);

    // Open the dialog
    if (brightnessDlg.DoModal() == IDOK)
    {
        // User pressed ok, fetch the value
        m_brightness = brightnessDlg.GetBrightness();
    }
}
 
Share this answer
 
v2
Comments
Sweety Khan 9-Jun-10 8:50am    
what is the difference between these two methods? i tried first one. in
first one, we also include header file #include "BrightnessDlg.h". does second one also needs the header file?

to show increase and decrese in brightness, which tool is better to use? slider control or something else?
Niklas L 9-Jun-10 16:49pm    
Both methods needs to include the header.
I think a slider will be great. Maybe with some kind of preview control to show the brightness?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900