-
May 13th, 2014, 12:35 AM
#1
Doc/View in CDialog
Hello,
I have a app with doc/view architekture.
Is it possible to show/edit a doc of this type also in a CDialog within this app?
How can I do that?
-
May 13th, 2014, 12:44 AM
#2
Re: Doc/View in CDialog
If I understand, you have a CDialog, where you can show/edit your CDocument ... you can get a pointer to CDocument, visible from anywhere, and based on this pointer, obviously, you can show/edit the content of CDocument into your CDialog ...
http://support.microsoft.com/kb/108587
Hope it helps.
-
May 13th, 2014, 01:07 AM
#3
Re: Doc/View in CDialog
In view , in a function call where u need to pass document pointer ...
u can use following method
Code:
void XYZView ::OnFunctionMyDialog
{
// TODO: Add your command handler code here
CXYZDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
Here u get document pointer
}
In your dialog , .h and .cpp files , overwrite the default constructor
pass document pointer to that ..
for eg
Code:
#include "XYZDoc.h" .... u will need this declaration
class CXYZDoc ;
// CMyDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMyDialog dialog
class CMyDialog : public CDialog
{
// Construction
public:
CMyDialog(CWnd* pParent ,CXYZDoc * pd); // standard constructor
CXYZDoc * pDoc;
}
In Dialog.cpp , modify the default constructor code
Code:
CMyDialog::CMyDialog(CWnd* pParent , CXYZDoc * pd )
: CDialog(CResultDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CResultDialog)
// dialog variables
pParent = NULL;
pDoc = pd; // here pass value to pointer
//}}AFX_DATA_INIT
}
Now u can use any variable from document via pDoc->.
In your view cpp ..
use code
Code:
void XYZView ::OnFunctionMyDialog
{
// TODO: Add your command handler code here
CXYZDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
Here u get document pointer
now pass it to dialog
CMyDialog * md;
md = new CMyDialog (NULL,pDoc);
( if u r using dialog from document .. the code will be
md = new CMyDialog(NULL,this);
this .. is doc ptr
)
md->DoModal();
delete(md);
}
Last edited by new_2012; May 13th, 2014 at 01:42 AM.
-
May 13th, 2014, 01:10 AM
#4
Re: Doc/View in CDialog
Originally Posted by Ralf Schneider
Hello,
I have a app with doc/view architekture.
Is it possible to show/edit a doc of this type also in a CDialog within this app?
How can I do that?
Do you mean you'd like a View looking like a dialog (with controls)?
Then use CFormView derived class as a View.
Victor Nijegorodov
-
May 13th, 2014, 01:13 AM
#5
Re: Doc/View in CDialog
Originally Posted by new_2012
In view , in a function call where u need to pass document pointer ...
u can use following method
Please, edit your post to correct Code tags: the closing tags use a slash, not a backslash.
Victor Nijegorodov
-
May 13th, 2014, 01:41 AM
#6
Re: Doc/View in CDialog
Sorry VictorN sir .. I have edited the code tags .. I will keep this in mind
-
May 13th, 2014, 03:36 AM
#7
Re: Doc/View in CDialog
Hello,
thanks for your answers.
But I think, I am completely misunderstood.
I try it again:
My app shows data during his doc/view architecture(classe CmyView/CmyDoc), normally.
But in a special case I want to open and show the some data also in a CDialog within this app.
How can I use my CmyView- and CmyDoc-classes also in this CDialog?
I need also the same behaviour and parts of my use interface in the CDialog.
-
May 13th, 2014, 03:44 AM
#8
Re: Doc/View in CDialog
Originally Posted by Ralf Schneider
...
I try it again:
My app shows data during his doc/view architecture(classe CmyView/CmyDoc), normally.
But in a special case I want to open and show the some data also in a CDialog within this app.
How can I use my CmyView- and CmyDoc-classes also in this CDialog?
I need also the same behaviour and parts of my use interface in the CDialog.
Well, you wrote nothing new comparing with your OP.
Thus I can only repeat my answer in the post#4: use CFormView derived class.
Victor Nijegorodov
-
May 13th, 2014, 07:14 AM
#9
-
May 13th, 2014, 08:15 AM
#10
Re: Doc/View in CDialog
Originally Posted by GCDEF
this goes in the right direction.
I will have a look on it tomorrow. Thank you.
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
|