I am New to MFC : program structure question 
Author Message
 I am New to MFC : program structure question

Hello, I am new to the exciting world of MFC programming, I have a couple of
questions that someone might be able to answer for me.
I understand the CMainFrame handles my menus, popups etc.  CDoc is for my
data, and CView is for my "view" of the CDoc.  Here is my question:  I have
data in the Doc, mostly CStrings...  Where is the CDoc object located?  Will
I just have the * CDoc in the CView class be the only object .   I noticed
it was created with new so there is a Doc object associated with the View
class, but is this the ONLY one?
Second, I have Sams Learn VC++ 21 Days - can anyone suggest another one?  it
is good but I would like one that provides another perspective of the way
all the different infastructure of standard MFC generated classes meld
together.

Thank You

Ray



Thu, 27 Nov 2003 07:04:08 GMT  
 I am New to MFC : program structure question

Quote:

> Hello, I am new to the exciting world of MFC programming, I have a couple of
> questions that someone might be able to answer for me.
> I understand the CMainFrame handles my menus, popups etc.  CDoc is for my
> data, and CView is for my "view" of the CDoc.  Here is my question:  I have
> data in the Doc, mostly CStrings...  Where is the CDoc object located?  Will
> I just have the * CDoc in the CView class be the only object .   I noticed
> it was created with new so there is a Doc object associated with the View
> class, but is this the ONLY one?
> Second, I have Sams Learn VC++ 21 Days - can anyone suggest another one?  it
> is good but I would like one that provides another perspective of the way
> all the different infastructure of standard MFC generated classes meld
> together.

> Thank You

> Ray

Not sure I understand your question but...  The doc object is typically
associated with a file. It is created when you open a file.  In an SDI
app there is only one doc, reused if you open a different file. An MDI
app has a separate doc for each open file.  Every doc can have an
unlimited number of views.

'Programming Windows With MFC' by Jeff Prosise provides an excellent
education.

--
Scott McPhillips [VC++ MVP]



Thu, 27 Nov 2003 08:24:46 GMT  
 I am New to MFC : program structure question
The Views are a way to represent data in the Doc...
For example, you could have multiple views Bar Charts, pie Graphs etc from
the Data in the Doc.
The Doc, is the only one.

I am not the best MFC programmer. I stick all my data in the view. I only
have one view.
It is probably not the best practice, but I do it anyways. Some day I will
pay for it...

Quote:
>>I understand the CMainFrame handles my menus, popups etc

This is not necessarily true. You can handle menu items in the View.
ClassWizard will create a OnWhateverMenuItem() where ever you want it.

Quote:
>>Where is the CDoc object located?

In Memory :) I am not sure what you mean. All I know is that you access it
with a pointer.

CMyView::OnSomeMenuItem()
{
    GetDocument()->MyCString = "What ever";

Quote:
}
> Second, I have Sams Learn VC++ 21 Days - can anyone suggest another one?

It's probably gonna take you longer than 21 Days.
I've been working with MFC for quite some time now and I am still learning.
I would reccomend Inside Visual C++ by David J. Kruglinski. Great Book.

Regards,

Quote:
> Hello, I am new to the exciting world of MFC programming, I have a couple
of
> questions that someone might be able to answer for me.
> I understand the CMainFrame handles my menus, popups etc.  CDoc is for my
> data, and CView is for my "view" of the CDoc.  Here is my question:  I
have
> data in the Doc, mostly CStrings...  Where is the CDoc object located?
Will
> I just have the * CDoc in the CView class be the only object .   I noticed
> it was created with new so there is a Doc object associated with the View
> class, but is this the ONLY one?
> Second, I have Sams Learn VC++ 21 Days - can anyone suggest another one?
it
> is good but I would like one that provides another perspective of the way
> all the different infastructure of standard MFC generated classes meld
> together.

> Thank You

> Ray



Thu, 27 Nov 2003 08:46:50 GMT  
 I am New to MFC : program structure question
Can someone provide an example of how to set the selected item in a combo
box?

If I have a document, a view, and a dialog, what is a simple way to go about
this?

I would like to use the App Wizard, but I don't see how.

So, I initialize the combo box in the dialog, then I would like to extract
the string that exists in the document (from a previous session), and set
the index of the combo box.  Also, after changing the selection, I would
like to update that document.

I've been trying to do this for days and I seem to be writing a whole lot
more code than I really should be writing.

Any help appreciated,
Chris


Quote:
> Hello, I am new to the exciting world of MFC programming, I have a couple
of
> questions that someone might be able to answer for me.
> I understand the CMainFrame handles my menus, popups etc.  CDoc is for my
> data, and CView is for my "view" of the CDoc.  Here is my question:  I
have
> data in the Doc, mostly CStrings...  Where is the CDoc object located?
Will
> I just have the * CDoc in the CView class be the only object .   I noticed
> it was created with new so there is a Doc object associated with the View
> class, but is this the ONLY one?
> Second, I have Sams Learn VC++ 21 Days - can anyone suggest another one?
it
> is good but I would like one that provides another perspective of the way
> all the different infastructure of standard MFC generated classes meld
> together.

> Thank You

> Ray



Thu, 27 Nov 2003 10:58:18 GMT  
 I am New to MFC : program structure question

Quote:

> Can someone provide an example of how to set the selected item in a combo
> box?

> If I have a document, a view, and a dialog, what is a simple way to go about
> this?

> I would like to use the App Wizard, but I don't see how.

> So, I initialize the combo box in the dialog, then I would like to extract
> the string that exists in the document (from a previous session), and set
> the index of the combo box.  Also, after changing the selection, I would
> like to update that document.

> I've been trying to do this for days and I seem to be writing a whole lot
> more code than I really should be writing.

> Any help appreciated,
> Chris

Something like this would be the usual way:

// in the view
   CMyDialog dlg(this);
   dlg.m_strSelect = GetDocument()->m_strSelect;
   if (dlg.DoModal() == IDOK)
      GetDocument()->m_strSelect = dlg.m_strSelect;

// in the dialog OnInitDialog
   m_combo.AddString("text");
   ...add several more strings
   m_combo.SelectString(0, m_strSelect);

If this is what you've been trying to do for days I suggest you study a
book.  Working through examples to become familiar with 'the usual way'
can help a lot!

--
Scott McPhillips [VC++ MVP]



Thu, 27 Nov 2003 22:14:40 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. I am new to programming and am lost

2. Hello Everyone, I am new to the MFC

3. Winsock 2 new functions and new structures

4. use keyboard structure INPUT in MFC program.

5. Program structure, multi-file design, several questions...

6. newbie question - program's structure

7. Program structure question

8. Question about redefining the global new and delete operators and MFC

9. Question about redefining the global new and delete operators and MFC

10. New-B MFC ActiveX Control question...

 

 
Powered by phpBB® Forum Software