C++ MFC

Moderators: Lundin
Number of threads: 3354
Number of posts: 9032

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Multiple views in a window Posted by empohjol on 9 Jul 2003 at 5:43 AM
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?
Report
Re: Multiple views in a window Posted by stober on 10 Jul 2003 at 4:23 AM
: 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?
:

sounds like an MDI project??
Report
Re: Multiple views in a window Posted by empohjol on 11 Jul 2003 at 6:10 AM
: : 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?
: :
:
: sounds like an MDI project??
:

Yes, and no. I have already many MDI-child windows, but I need multiple views in every child window.
Report
Re: Multiple views in a window Posted by stober on 11 Jul 2003 at 8:38 PM
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.

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);

	
}






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.