multiple views in 1 documentwindow 
Author Message
 multiple views in 1 documentwindow

Who can help me?

I'm trying to create a CMDIChildWnd derived documentwindow,
with 1 till 4 views in it, depending on what the user wants.
(so it should be able to change it during runtime)
It have  tried to do it with a splitterwindow, but I don't
think it can work the way I want to. The views should scale
during the scaling of the window. I want to have several
kinds of groupings of views. For example, just 1 view, or
3 views on the left and 1 right. Or 2 left 2 right.
It should be able to switch between it. Here's what it should
look like a bit.
__________          ___________          _____________
|        |          |__|      |          |     |     |
|        |    or    |__|      |    or    |_____|_____|
|________|          |__|______|          |     |     |

I thought I had it working until I tried to "Cascade" and
after that "Tile" the windows. But the scaling of the window
(and therefore the views), and the activation of a view works OK.

It seemed that not all the views where drawn properly after
tiling. Most of the times the last 1 or 2 views weren't drawn
at all. Moving such a window causes {*filter*}to be placed in the
place of a missing view. Only after resizing that window,
or cascading all windows, the all views are drawn properly.

Another major problem I have, is with the built-in print preview.
Print-preview uses the same window it makes a preview of.
So the views are replaced by another view probably.
But at the place of the buttons for the print preview, parts
of my views stay in sight.
(In my case the print preview should be either the active view
in the active documentwindow, or if possible alle the views of
the active ducometnwindow.)

My views are programmed to react on mouse-input. Clicking
on a view causes a line to be drawn at the border. Clicking
in the print-preview, it also reacts on it.

Another (small) problem I have with print preview is the
following. The views are not the only thing displayed in the
documentwindow. I also need 2 gray panes at the left and bottom
of the documentwindow with some text in it. Rescaling the print
preview window, causes these panes to be drawn during the scaling.

Here's the main source code how I made it.
It's the code for the function OnCreateClient for the


// MYWND.H // shortened of course

Class CMyWnd : public CMDIChildWnd  // shortened of course
        #define MAX_NUMBER_OF_VIEWS 4
        CMyView *pView[MAX_NUMBER_OF_VIEWS]


// MYWND.CPP // shortened of course

BOOL CMyWnd::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
        // setting the size of the documentwindow

        // creating the multiple views
        for (int i=0;i<MAX_NUMBER_OF_VIEWS;i++)
                pView[i] = (CMyView*) CreateView(pContext, AFX_IDW_PANE_FIRST);
                if (!pView[i])
                        TRACE0("Failed to create view\n");
                        return FALSE;

        // Setting the size and position of all the views in the documentwindow.
        // areaInParent is a CRect with the right size and position.
        // areaInParent is calculated everytime the OnDraw function of
        // the class CMyView is called. (and once before the next for statement)
        for (int i=0;i<MAX_NUMBER_OF_VIEWS;i++)
                pView[i]->SetWindowPos(&wndTop, pView[i].areaInParent.TopLeft().x,
                                                pView[i].areaInParent.Height(), SWP_SHOWWINDOW);

        return TRUE;



I hope someone can help me, would be great.

Wiebe Jaspers

Sun, 03 Dec 2000 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Multiple views in 1 documentwindow

2. Multiple views = multiple recordsets?

3. Multiple view, multiple windows?

4. Multiple documents or multiple views one document

5. multiple Documents and multiple views

6. should I use multiple views or multiple dialogs?

7. Conventions for multiple views of multiple documents

8. Multiple view, multiple windows?

9. Single Document// multiple views// multiple frames

10. Multiple documents or multiple views one document

11. How to modify the Title of each view in Multiple view / one document app

12. Multiple selections in EditCtrl/View and RichEditCtrl/view


Powered by phpBB® Forum Software