Home > Software engineering >  MFC split view size problem
MFC split view size problem

Time:09-20

Creates a static view
The code below
 BOOL CMainFrame: : OnCreateClient (LPCREATESTRUCT LPCS, CCreateContext * pContext) 
{
//TODO: add in this dedicated code and/or call the base class

//create a static window, divided into two columns, one line
if (! M_splitter. CreateStatic (this, 1, 2))
return FALSE;

If (m_splitter1. CreateStatic (& amp; M_splitter, 2, 1, WS_CHILD | WS_VISIBLE, m_splitter. IdFromRowCol (0, 0))==NULL)
return FALSE;
//will FormView1 link to the second column column object row 0 0
If (m_splitter1. CreateView (0, 0, RUNTIME_CLASS (FormView1), CSize (400, 400), pContext)==NULL)
return FALSE;
//will FormView2 class 1 row of links to the second column object column 0
M_splitter1. CreateView (1, 0, RUNTIME_CLASS (FormView2), CSize (400, 200), pContext);
//will COTDRView link line 1 0 column pane
M_splitter. CreateView (0, 1, RUNTIME_CLASS (RightView), CSize (100, 600), pContext);
return TRUE;
}

But the view is always the right to occupy all the size of the diagram below:
So overloaded onsize to set the view size, but would have been an error , the companion code, there is no problem, so you also want to give a great god some directions!

CodePudding user response:

Debug, single-step tracking, line positioning error

CodePudding user response:

Debug, single-step tracking, line positioning error

CodePudding user response:

OnSize need to judge whether the HWND effective first:

 if (NULL! .=m_splitwnd GetSafeHwnd ()) 
{
CRect the rect.
GetClientRect (... );
M_splitwnd. SetRowInfo ();
M_splitwnd. SetColumnInfo ();
M_splitwnd. RecalcLayout ();
}

CodePudding user response:

Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, double-click on the next line when don't understand, until can understand,

CodePudding user response:

If (IsWindow (m_Splitter m_hWnd))

CodePudding user response:

3 and 5 floor thought because OnSize will perform before OnCreateClient so, right at the first time into the OnSize splitter is empty has not been created, the need for judgment, but 3 and 5 floor method I tried no effect into execution, so I'm splitter. The CreateStatic after adding tags m_bIsSplitterCreate=TRUE, the first in the OnSize judgment if (m_bIsSplitterCreate==TRUE)

CodePudding user response:

By whom 2016 posts top up
  • Related