S
suncuigang
Guest
Hi,everyone:
In my program,I wanna creat static splitter views again in the static splitter window of a CSplitterWndEx.
For example, I creat 2x2 windows in mainFrm , in each window, I creat 2x2 views.
In MainFrm.h:
I add:
CSplitterWndEx m_splitter,splitter[2][2];
BOOL m_flag=false;
I overwrote OnCreateClient:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_splitter.CreateStatic(this,2,2);
m_splitter.CreateView( i, j, RUNTIME_CLASS(CWnd),CSize(10,10), pContext);
for(int i=0; i<2; i++)
for(int j=0; j<2; j++)
{
splitter[j].CreateStatic(m_splitter.GetPane(i,j),2,2);
for (int m=0;m<2;m++)
for (int n=0;n<2;n++)
{
splitter[j].CreateView(m,n,RUNTIME_CLASS(CView),CSize(10,10),pContext);
}
}
m_flag =TRUE;
return TRUE;
}
And wrote OnSize:
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWndEx::OnSize(nType, cx, cy);
CRect rect;
int Gap = 1;
int Border=1;
m_splitter.GetClientRect( &rect );
if(m_splitter.GetSafeHwnd() && m_flag&&!rect.IsRectEmpty())
{
for(int i=0; i<2; i++)
m_splitter.SetRowInfo(i, (rect.Height()-(2-1)*Gap-2*Border)/2, 1);
for(int i=0; i<COLS; i++)
m_splitter.SetColumnInfo(i, (rect.Width()-(2-1)*Gap-2*Border)/2, 1);
m_splitter.RecalcLayout();
CRect rect4[2][2];
for (int i=0;i<2;i++)
for (int j=0;j<2;j++)
{
splitter[j].GetClientRect(&rect4[j]);
if (splitter[j].GetSafeHwnd()&&m_flag&&!rect4[j].IsRectEmpty())
{
for (int m=0;m<2;m++)
{
splitter[j].SetRowInfo(m, (rect4[j].Height()-(2-1)*Gap-2*Border)/2, 1);
}
for (int n=0;n<2;n++)
{
splitter[j].SetColumnInfo(n, (rect4[j].Width()-(2-1)*Gap-2*Border)/2, 1);
}
splitter[j].RecalcLayout();
}
}
}
As a result, it only showed a 2x2 CWnd. In each wnd,there are no static splitter views.
So,Is there any way to creat static splitter windows again in the static splitter window of a CSplitterWndEx using MFC?
Any suggestion will be appreciated!
Continue reading...
In my program,I wanna creat static splitter views again in the static splitter window of a CSplitterWndEx.
For example, I creat 2x2 windows in mainFrm , in each window, I creat 2x2 views.
In MainFrm.h:
I add:
CSplitterWndEx m_splitter,splitter[2][2];
BOOL m_flag=false;
I overwrote OnCreateClient:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_splitter.CreateStatic(this,2,2);
m_splitter.CreateView( i, j, RUNTIME_CLASS(CWnd),CSize(10,10), pContext);
for(int i=0; i<2; i++)
for(int j=0; j<2; j++)
{
splitter[j].CreateStatic(m_splitter.GetPane(i,j),2,2);
for (int m=0;m<2;m++)
for (int n=0;n<2;n++)
{
splitter[j].CreateView(m,n,RUNTIME_CLASS(CView),CSize(10,10),pContext);
}
}
m_flag =TRUE;
return TRUE;
}
And wrote OnSize:
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWndEx::OnSize(nType, cx, cy);
CRect rect;
int Gap = 1;
int Border=1;
m_splitter.GetClientRect( &rect );
if(m_splitter.GetSafeHwnd() && m_flag&&!rect.IsRectEmpty())
{
for(int i=0; i<2; i++)
m_splitter.SetRowInfo(i, (rect.Height()-(2-1)*Gap-2*Border)/2, 1);
for(int i=0; i<COLS; i++)
m_splitter.SetColumnInfo(i, (rect.Width()-(2-1)*Gap-2*Border)/2, 1);
m_splitter.RecalcLayout();
CRect rect4[2][2];
for (int i=0;i<2;i++)
for (int j=0;j<2;j++)
{
splitter[j].GetClientRect(&rect4[j]);
if (splitter[j].GetSafeHwnd()&&m_flag&&!rect4[j].IsRectEmpty())
{
for (int m=0;m<2;m++)
{
splitter[j].SetRowInfo(m, (rect4[j].Height()-(2-1)*Gap-2*Border)/2, 1);
}
for (int n=0;n<2;n++)
{
splitter[j].SetColumnInfo(n, (rect4[j].Width()-(2-1)*Gap-2*Border)/2, 1);
}
splitter[j].RecalcLayout();
}
}
}
As a result, it only showed a 2x2 CWnd. In each wnd,there are no static splitter views.
So,Is there any way to creat static splitter windows again in the static splitter window of a CSplitterWndEx using MFC?
Any suggestion will be appreciated!
Continue reading...