-
November 18th, 2004, 11:01 PM
#1
Loading data in a View without Doc
I have a MDI application without Doc/View support. My problem is to load information in the view.
I Create a first view with control inside (CtreeView). This view create a other one (derive from CView) where I would like show my data. To view this data I have to transfert information between the first view and the second one. I shoud like to have a varaible in my view object where I can transfert this information after the creation of the view. I don't know how to acces a varaible like that
Thank you
-
November 19th, 2004, 03:38 PM
#2
Re: Loading data in a View without Doc
Since there is no document available, you need to look for what is commonly available between the two view classes. That would be the mainframe class or CWinApp class. So that leaves you with a few options:
1) Store your data in the CMainFrame class directly
2) Embed a class that contains the data in the CMainFrame class
3) In either case access the CMainFrame class from each view with AfxGetMainWnd(). You may want to create Get/Set accessors to the data for use by the views.
4) or -- do 1, 2, and 3 but use the CWinApp class and access with AfxGetApp().
Arjay
-
November 19th, 2004, 05:48 PM
#3
Re: Loading data in a View without Doc
In addition to Arjay post, consider reverting to a doc/view architecture.
That is a classic scenario where you would appreciate having doc/view support.
Both views wired to the same document have access to common data in a document taking advantage of UpdateAllViews for example.
You can have both views in the same frame using splitter.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
November 22nd, 2004, 11:57 AM
#4
Re: Loading data in a View without Doc
I didn't use a Doc\View application because the only Data are use is from a MySQL database. Is it a Doc can help me to load data from a MySQL Database? The data I have to transfert between views are request string or other things like that.
-
November 22nd, 2004, 12:08 PM
#5
Re: Loading data in a View without Doc
Retrieving database data would require the same code. Accessing data and maintaining changes in multiple views is much easier if doc/view architecture is supported.
Each time anything changes, UpdateAllViews will notify views. It is really easy to access document, since each view has GetDocument function returning pointer to a document.
That is the whole idea of doc/view architecture. Data for display exists in a document object; views are means of displaying this data.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
November 22nd, 2004, 12:38 PM
#6
Re: Loading data in a View without Doc
In addition, if the data you wish to view comes from the same database, then it sounds like you need an SDI (Single Doc Interface) app with multiple views rather than the MDI app you currently have.
Since there is only only one doc in a SDI, this would be the doc that would tie all the views together. In contrast, in a MDI, for every view there is a separate doc and each doc doesn't naturally 'communicate' with any other document.
Consider using multiple view in a splitter window or using a main view and a second view inside a CDialogBar (for a dockable, movable view).
-
November 22nd, 2004, 12:51 PM
#7
Re: Loading data in a View without Doc
Originally Posted by Arjay
In addition, if the data you wish to view comes from the same database, then it sounds like you need an SDI (Single Doc Interface) app with multiple views rather than the MDI app you currently have.
Since there is only one doc in a SDI, this would be the doc that would tie all the views together. In contrast, in a MDI, for every view there is a separate doc and each doc doesn't naturally 'communicate' with any other document.
Arjay you need to revise your statement.
In both MDI and SDI you can show multiple views in one frame that are wired to the same document.
In MDI you can even create new frame with view that share one document object.
Furthermore SDI application can have more than one document type if you register more than one document template.
Splitter window can work in both MDI and SDI. Depending on a need to open multiple sources from database MDI may be a valid choice too.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
November 22nd, 2004, 01:13 PM
#8
Re: Loading data in a View without Doc
John, I was referring to the default general usage of SDI and MDI. It sounds like for this case, SDI with multiple views would be a good start.
-
November 22nd, 2004, 01:22 PM
#9
Re: Loading data in a View without Doc
Originally Posted by Geof
I didn't use a Doc\View application because the only Data are use is from a MySQL database. Is it a Doc can help me to load data from a MySQL Database? The data I have to transfert between views are request string or other things like that.
That's a common misconception about the document/view architecture. A "document" doesn't have to be a document file, like a Word document: It can be any kind of source or container for your data: You can use documents with a database, data coming from a serial port, from an internet connection etc.: Its only concern is to separate the data from its presentation.
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
|