liseperu
asked on
mfc dialog buttons not working
hi
i have created a simple app interface
and i am just at intial stages and have run into prbs
i have a main window that interherits from the CDialog class
all the buttons work fine on this window
i have one button that opens another window
which will have some data input boxes on
i have create a simple button to just bling up a messagebox when pressed
the thing is it doesnt do anything!!!
i have added control variable in the class wizard member variables but all to now effect
heres the handler code---------------------- ---------- ----
void Second_Interface::OnTestBu tt()
{
// TODO: Add your control notification handler code here
MessageBox( "Test.","Test", MB_YESNO | MB_ICONQUESTION );
}
-------------------------- ---------- ---------- ---------- ---------
i think i have done something wrong when creating classes
or when i open the window froem the main area
the second window inherits from hte CDialog class
is the the write way to do it
or should it inherit from the main window class
thanks
lis
i have created a simple app interface
and i am just at intial stages and have run into prbs
i have a main window that interherits from the CDialog class
all the buttons work fine on this window
i have one button that opens another window
which will have some data input boxes on
i have create a simple button to just bling up a messagebox when pressed
the thing is it doesnt do anything!!!
i have added control variable in the class wizard member variables but all to now effect
heres the handler code----------------------
void Second_Interface::OnTestBu
{
// TODO: Add your control notification handler code here
MessageBox( "Test.","Test", MB_YESNO | MB_ICONQUESTION );
}
--------------------------
i think i have done something wrong when creating classes
or when i open the window froem the main area
the second window inherits from hte CDialog class
is the the write way to do it
or should it inherit from the main window class
thanks
lis
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok
i think i need a modal one as i want the user to complete the inputs in the second window before returning to the first
so should i use
-------------------------- ---------- -----
IDD_DIALOG2 dlg(this);
dlg.DoModal();
-------------------------- ---------- ---
thanks
i think i need a modal one as i want the user to complete the inputs in the second window before returning to the first
so should i use
--------------------------
IDD_DIALOG2 dlg(this);
dlg.DoModal();
--------------------------
thanks
Not quite. You derive a class from CDialog (eg. CMyDialog) which is using the resource with the ID IDD_DIALOG2. Then you use
CMyDialog dlg(this);
if(dlg.DoModal()==IDOK)
{
//OK button pressed
}
else
{
//cancel pressed
}
CMyDialog dlg(this);
if(dlg.DoModal()==IDOK)
{
//OK button pressed
}
else
{
//cancel pressed
}
ASKER
thanks
that works fine
but it htakes about 5 seconds to open
i have been checkin out classes
and this is what i have got
i have two interfaces Cinterface1 , Cinterface2
class CInterface1 : public CDialog
class CInterface2 : public CDialog
i am trying to call interface 2 from interface 1
any ideas why it is taking so long
here the open dialog code
void CInterface1::OnEnterCInter face1()
{
// TODO: Add your control notification handler code here
CInterface2 sDlg;
sDlg.DoModal();
}
thanks
lis
that works fine
but it htakes about 5 seconds to open
i have been checkin out classes
and this is what i have got
i have two interfaces Cinterface1 , Cinterface2
class CInterface1 : public CDialog
class CInterface2 : public CDialog
i am trying to call interface 2 from interface 1
any ideas why it is taking so long
here the open dialog code
void CInterface1::OnEnterCInter
{
// TODO: Add your control notification handler code here
CInterface2 sDlg;
sDlg.DoModal();
}
thanks
lis
ASKER
arh sorry
i am such a dozy cow
forget about my post above
i think the problem is that the smaller interface2 window was is hidden
behind the rather large interface1 window
it is kind of hard to tell cus i cant mimize the big window
is there a simple line of code to ensure that the second windowopens on top of the first?
thanks
sarah
i am such a dozy cow
forget about my post above
i think the problem is that the smaller interface2 window was is hidden
behind the rather large interface1 window
it is kind of hard to tell cus i cant mimize the big window
is there a simple line of code to ensure that the second windowopens on top of the first?
thanks
sarah
ASKER
hello again
i think there must havebeen a bug inthe program
i open an older version of the program and inserted the code as suggest above
and it worked fine
i inserted the following ode to opena modal dialoge
CInterface2 sDlg;
sDlg.DoModal();
into the button handler
and bingo it worked fine
thanks again
i think there must havebeen a bug inthe program
i open an older version of the program and inserted the code as suggest above
and it worked fine
i inserted the following ode to opena modal dialoge
CInterface2 sDlg;
sDlg.DoModal();
into the button handler
and bingo it worked fine
thanks again
ASKER
i was going to post another question about the diference between modal and modeless
which i dont understand
anyway i just opened a modaless using the code below
--------------------------
CDialog* pDialog;
pDialog = new CDialog();
pDialog->Create(IDD_DIALOG
pDialog->ShowWindow(SW_SHO
pDialog->CenterWindow();
--------------------------
is this ok?
lis