Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC
I have CMainFrame class for my main window, and CChildView class for my view as generated by AppWizard. I have created two CChildView objects to represent two different view (client area Panels for controls) using m_wndView1.Create() and m_wndView2.Create(). but the ID used in the Create() function seem to be a problem. If its not AFX_IDW_PANE_FIRST the view does not display. Please I need a pointer to learn about the ID and how to solve the problem. Thanks.
 
 // MainFrm.cpp

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
 
	//create a view to occupy the client area of the frame
	
	m_wndView1.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
		CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL);
	
	
	
	m_wndView2.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
		CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST+1, NULL);
	
	pM_wndView1 = &m_wndView1;
	pM_wndView2 = &m_wndView2;
	
	
	// create controls to occupy the client pane of the frame
	
	RECT rect1;
	rect1.left = 20; //distance from left of client area
	rect1.top = 100; //distance from top of client area
	rect1.right  = 95; //Length of rectangle 75 + distance from left of client area 20
	rect1.bottom = 125; //Hight of rectangle 25 + distance from top of client area 100
	
	
	myButton.Create(_T("First"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rect1, pM_wndView1, B_ID);
	
	m_wndView2.ShowWindow(SW_SHOW); // Here i like to test the two view before using them
	return 0;
}
Posted 26-Feb-13 4:38am
Edited 27-Feb-13 0:39am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Anthony Oyovwe at 26-Feb-13 16:58pm
   
@Richard, thanks for the post but my app is not a document/view app.
Richard MacCutchan at 26-Feb-13 17:10pm
   
Then you need to provide more information. From the above it is not clear what you are trying to do and why it does not work.
Anthony Oyovwe at 27-Feb-13 5:21am
   
I want to use different objects of the CChildView to create many views which i can switch at runtime, but when i test the second view, it doesnt work because of the ID. See updated post.
Richard MacCutchan at 27-Feb-13 5:46am
   
I am still not sure what you mean by "doesn't work because of the ID". Each view is a window and should have a unique ID, and you can make an individual view visible by using the id. Take a look at this MSDN page for some sample code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.150326.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100