Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C++
 // 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
Updated 26-Feb-13 23:39pm
v2

1 solution

 
Share this answer
 
Comments
Tonex247 26-Feb-13 16:58pm    
@Richard, thanks for the post but my app is not a document/view app.
Richard MacCutchan 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.
Tonex247 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900