Multiple views in a window - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Multiple views in a window

empohjolempohjol Posts: 3Member
How can I have multiple views (derived from CView) in a window's clien area (CWnd), without a splitter window?
I need to be able to place the views freely in the window, and later move them. Can somebody tell me how to create the views, attach a document to it, move it to the right place in the window and show it.

Another following question: Is it possible to receive mouse messages in the view when the mouse passes over it, that are relative to the upper-left corner of the view?

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    : How can I have multiple views (derived from CView) in a window's clien area (CWnd), without a splitter window?
    : I need to be able to place the views freely in the window, and later move them. Can somebody tell me how to create the views, attach a document to it, move it to the right place in the window and show it.
    :
    : Another following question: Is it possible to receive mouse messages in the view when the mouse passes over it, that are relative to the upper-left corner of the view?
    :

    [blue]sounds like an MDI project??[/blue]
  • empohjolempohjol Posts: 3Member
    : : How can I have multiple views (derived from CView) in a window's clien area (CWnd), without a splitter window?
    : : I need to be able to place the views freely in the window, and later move them. Can somebody tell me how to create the views, attach a document to it, move it to the right place in the window and show it.
    : :
    : : Another following question: Is it possible to receive mouse messages in the view when the mouse passes over it, that are relative to the upper-left corner of the view?
    : :
    :
    : [blue]sounds like an MDI project??[/blue]
    :

    Yes, and no. I have already many MDI-child windows, but I need multiple views in every child window.
  • stoberstober Posts: 9,765Member ✭✭✭
    I've had some success at doing it with a simple CView-derived class. The class below is the original view. I have been able to make the window resizeable, but not moveable.

    [code]
    void CTestViewView::OnInitialUpdate()
    {
    CView::OnInitialUpdate();
    // This code creates another CView view and
    // attaches it to the top-half of the current
    // view.
    ModifyStyle(0,WS_MAXIMIZE);
    CMyEditView *pEditView;
    pEditView = new CMyEditView;
    CDocument* pDoc = GetDocument();
    // The new view will occupy the top half of
    // the parent's window area.
    CRect rect;
    GetClientRect(rect);
    rect.bottom /= 2;
    // This attaches the new view to the CDocument
    // class.
    CCreateContext context;
    context.m_pCurrentDoc = pDoc;
    // The styles are not quite righ. Windows does not seen to
    // like or use all the styles listed below.
    pEditView->Create(NULL,
    "CMyEditViewClass",
    WS_CHILD | WS_VISIBLE | WS_THICKFRAME|WS_BORDER|WS_OVERLAPPED|WS_SYSMENU|WS_CAPTION|
    WS_MAXIMIZEBOX | WS_MINIMIZEBOX, rect, this,100, &context);


    }
    [/code]


Sign In or Register to comment.