Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with DialogBox

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is it possiable to use one Dialog box with todifferent class, is it also possible to turn off/on controls when required by the classes.

How can one do this, i tried it by making a simple dialog box, and used two different calling OnMenu Buttons.

Dialogbox has a buttons saing "Save".

Functions to load dialog box.

CTestApp::OnMenu12()
{
CDia Dlg;
Dlg.DoModal();
\\want Save button in active
}

CTestApp::OnMenu78()
{
CDia Dlg;
Dlg.DoMOdal();
\\want save button to be active
}

How can i implement the IN/AVTIVE function, PLS HELPPPPPP...
 
What I would do is override the dialog constructor. Then pass which Menue item activated the dlg, and store that in a member variable, m_From. Like so:

CDia::CDia(int from):CDialog(CDia::IDD, pParent)
{
m_From = from;
}

BOOL CDia::OnInitDialog()
{
CDialog::OnInitDialgo();
if (m_From == 12)
c_SaveButton.ShowWindow(false);
if (m_From == 78)
c_SaveButton.ShowWindow(true);

return TRUE;
}

Then

CTestApp::OnMenu12()
{
CDia Dlg(12);
Dlg.DoModal();
\\want Save button in active
}

the c_SaveButton variable is a CButton type which is mapped in DoDataExchange like

DDX_Control(pDX, IDC_SAVE_BUTTON, c_SaveButton);

Is that whay you were trying to do?

CJB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top