|
-
April 19th, 2006, 01:12 AM
#1
two dialogs to same class
Hi all,
Can we add two dialogs to the same class?
Consider two dialogs A and B of class clz.
now if i make a call as
clz obj;
obj.DoModal();
here which dialog is invoked.
Thank u.
-
April 19th, 2006, 01:25 AM
#2
Re: two dialogs to same class
This is somehow a strange feature. Maybe if you explain what you want to achieve, we can give you some advice.
-
April 19th, 2006, 01:38 AM
#3
Re: two dialogs to same class
I want to invoke dialog A or B depending upon my requirements.
-
April 19th, 2006, 02:30 AM
#4
Re: two dialogs to same class
But, they behave different?
If so, make 2 classes. Then, in the class which implements your special requirements, you invoke the right dialog:
Code:
if (bShowDialogA)
{
CMyADlg dlgA;
dlgA.DoModal();
}
else
{
CMyBDlg dlgB;
dlgB.DoModal();
}
-
April 19th, 2006, 03:27 AM
#5
Re: two dialogs to same class
A dialog Creation depends on the ID of the Dialog .and it's upto you which id you are going to provide to your dialog .and on the basis of IDD u can make a call to your apropriate dialog .
Thankyou
Last edited by humptydumpty; April 19th, 2006 at 06:20 AM.
-
April 19th, 2006, 06:04 AM
#6
Re: two dialogs to same class
 Originally Posted by harshandu
Hi all,
Can we add two dialogs to the same class?
Consider two dialogs A and B of class clz.
now if i make a call as
clz obj;
obj.DoModal();
here which dialog is invoked.
Thank u.
Of course we can "add" two dialogs to the same class.
We should make it clear that a "dialog" is a kind of resource.
And it's identified by its ID (always IDD_ heading).
We Create a dialog class inherits from CDialog,it doesn't mean that we
must attach a dialog ID to it.
for example:
class CMyDlg: public CDialog
{
CMyDlg(CWnd* pParentWnd = NULL); //Standard construction
CMyDlg(UINT nIDTemplate, CWnd* pParentWnd = NULL); //Not standard
virtual ~CMyDlg();
...
}
We can use this dialog class in this way:
CMyDlg *pMyDlg1;
CMyDlg *pMydlg2;
ok,now,if you want any of the two dialog to be a Mode dialog:
pMyDlg1 = new CMyDlg(IDD_DIALOG_ONE,pParentWnd);
pMyDlg2 = new CMyDlg(IDD_DIALOG_TWO,pParentWnd);
//Note: pParentWnd can be NULL
pMyDlg1->DoModal(); //Create and activate it!
pMyDlg2->DoModal();
If you want them to be Modeless,do in this way:
pMyDlg1 = new CMyDlg(pParentWnd);
pMyDlg2 = new CMyDlg(pParentWnd);
//Note: pParentWnd also can be NULL
pMyDlg1->Create(IDD_DIALOG_ONE,pParentWnd);
pMyDlg2->Create(IDD_DIALOG_TWO,pParentWnd);
pMyDlg1->ShowWindow(SW_SHOW);
pMyDlg2->ShowWindow(SW_SHOW);
In this way, many dialogs can share one class,isn't it great?
Wisby
4\19\2006
-
April 19th, 2006, 06:12 AM
#7
Re: two dialogs to same class
PS:the not standard construction is like this:
CMyDlg::CMyDlg(UINT nIDTemplate, CWnd* pParentWnd)
: CDialog(nIDTemplate, pParentWnd)
{
//{{AFX_DATA_INIT(CMyDlg)
// member initials here
//}}AFX_DATA_INIT
}
Over....haha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|