How to make a child window a CView 
Author Message
 How to make a child window a CView

Hi, I am relatively new to MFC so forgive this simple question.

I am writing a little drawing program for MFC practice. The only view
covers the entire client area of the child frame. The view is created
using CMultiDocTemplate.

Anyway, now I wamt to add add horizontal and vertical rulers to the
application

They rulers of course will be inside the child frame and the drawing
area will be inside the rulers. I want the rulers and the drawing area
to be seperate windows to facilite drawing and clipping etc.

So I will either make CDrawView, CVertRuler and CHorzRuler a child of
the child frame OR I will make CDrawView, CVertRuler and CHorzRuler a
child of a child of the child frame.

Anyway, I can figure out how to do this with CMultiDoc which defaults
the CDrawView to cover the entire client area. Basically, I need to
know how to create a child CView of a window and attach a document to
it. I don't want the framework to do it automatically.

I know this question is not so clear but any help would be appreciated

Regards

Peter



Thu, 10 Nov 2005 09:04:21 GMT  
 How to make a child window a CView

Quote:

> Hi, I am relatively new to MFC so forgive this simple question.

> I am writing a little drawing program for MFC practice. The only view
> covers the entire client area of the child frame. The view is created
> using CMultiDocTemplate.

> Anyway, now I wamt to add add horizontal and vertical rulers to the
> application

> They rulers of course will be inside the child frame and the drawing
> area will be inside the rulers. I want the rulers and the drawing area
> to be seperate windows to facilite drawing and clipping etc.

> So I will either make CDrawView, CVertRuler and CHorzRuler a child of
> the child frame OR I will make CDrawView, CVertRuler and CHorzRuler a
> child of a child of the child frame.

> Anyway, I can figure out how to do this with CMultiDoc which defaults
> the CDrawView to cover the entire client area. Basically, I need to
> know how to create a child CView of a window and attach a document to
> it. I don't want the framework to do it automatically.

> I know this question is not so clear but any help would be appreciated

> Regards

> Peter

There are several ways to do this.  The one I prefer is to use a
CFormView as the view that fills the frame. Let MFC automatically create
and manage that one.  You can put anything you want on it, such as
rulers, controls, toolbar, status bar.  Then to put your original
CDrawView on it you can copy and adapt the MFC code from
CSplitterWnd::CreateView.  This covers the details of hooking it up to
the document and sending it WM_INITIALUPDATE.

Then in the formview's OnSize handler you will need code that resizes
the children, including the CDrawView, whenever the CFormView size is
changed.  You will also want to call SetScrollSizes(MM_TEXT, CSize(cx,
cy)) with the new size to eliminate the scroll bars that CFormView
inherits.

--
Scott McPhillips [VC++ MVP]



Thu, 10 Nov 2005 11:11:31 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CView with a CView child help

2. Printing child windows from CView

3. Activating a CWnd child window of a CView

4. CView child window navigation

5. What makes the child window resize to fit its parent

6. Making an MDI child window initially maximized

7. Making a MDI child window using CreateWindowEx() ?

8. Making a MDI Child window go modal!!

9. Getting a handle to a child window / Resizing a child window

10. Child Window in Child Window

11. Getting a handle to a child window / Resizing a child window

12. Making a CView stay on top.

 

 
Powered by phpBB® Forum Software