Visual C++单文档分割了两个窗口!
BOOL rtn=SplitterH.CreateStatic(this,2,1);SplitterH.SetRowInfo(1,150,0);
SplitterH.SetRowInfo(0,150,0);请问我如何将我的这两个窗口其中一个随我的单文档程序尺寸变化而变化,另一个始终不变,而且不要显示那个分割线,我想隐藏起来。
这个应该怎么做
BOOL rtn=SplitterH.CreateStatic(this,2,1);SplitterH.SetRowInfo(1,150,0);
SplitterH.SetRowInfo(0,150,0);请问我如何将我的这两个窗口其中一个随我的单文档程序尺寸变化而变化,另一个始终不变,而且不要显示那个分割线,我想隐藏起来。
这个应该怎么做
//假如你要固定大小
SplitterH.SetRowInfo(1,150,0);
SplitterH.SetRowInfo(0,150,0);
SplitterH.RecalcLayout();
函数里根据事件的参数cx、cy计算新的分
割窗口的大小,然后调用CSplitterWnd的
void SetColumnInfo( int col, int cxIdeal, int cxMin );
或void SetRowInfo( int row, int cyIdeal, int cyMin );
最后调用CSplitterWnd的
RecalcLayout( ); 编译成功,但就是不能运行
void CMySplitterWnd::OnMouseMove(UINT nFlags, CPoint point) //实现固定
{
CRect rt;
GetClientRect(&rt);
//if(point.x<=rt.Width()/6||point.x>=rt.Width()*5/6)
if(point.y<=rt.Height()/6||point.y>=rt.Height()*5/6)
CWnd::OnMouseMove(nFlags,point);
else
CSplitterWnd::OnMouseMove(nFlags, point);
}
virtual void OnDrawSplitter(CDC* pDC, ESplitType nType, const CRect& rectArg);
void CMySplitterWnd::OnDrawSplitter(CDC* pDC, ESplitType nType, const CRect& rectArg)//绘制拆分条
{ // if pDC == NULL, then just invalidate
if (pDC == NULL)
{
RedrawWindow(rectArg, NULL, RDW_INVALIDATE|RDW_NOCHILDREN);
return;
}
ASSERT_VALID(pDC); // otherwise, actually draw
CRect rect = rectArg;
switch (nType)
{
case splitBorder:
pDC->Draw3dRect(rect, RGB(255,120,255), RGB(255,120,255));
rect.InflateRect(-1, -1);
pDC->Draw3dRect(rect, RGB(255,120,255), RGB(255,120,255));
return; case splitIntersection:
break; case splitBox:
pDC->Draw3dRect(rect, RGB(255,0,0), RGB(255,0,0));
rect.InflateRect(-1, -1);
pDC->Draw3dRect(rect, RGB(255,0,0),RGB(255,0,0));
rect.InflateRect(-1, -1);
break; case splitBar:
break; default:
ASSERT(FALSE); // unknown splitter type
} // fill the middle
COLORREF clr = RGB(228,228,228);
pDC->FillSolidRect(rect, clr);
}void CMySplitterWnd::OnInvertTracker(const CRect& rect) //拖动时候绘制虚框
{
//return CSplitterWnd::OnInvertTracker(rect);;
ASSERT_VALID(this);
ASSERT(!rect.IsRectEmpty());
ASSERT((GetStyle()&WS_CLIPCHILDREN)==0);
CRect rc=rect;
rc.InflateRect(2,2);
CDC* pDC=GetDC();
CBrush* pBrush=CDC::GetHalftoneBrush();
HBRUSH hOldBrush=NULL;
if(pBrush!=NULL) hOldBrush=(HBRUSH)SelectObject(pDC->m_hDC,pBrush->m_hObject);
pDC->PatBlt(rc.left,rc.top,rc.Width(),rc.Height(),PATINVERT); if(hOldBrush!=NULL)
SelectObject(pDC->m_hDC,hOldBrush);
ReleaseDC(pDC); }
void CMySplitterWnd::HideRow(int _row) //隐藏某一行
{
int nActiveRow, nActiveCol; // if the nRow has an active window -- change it
if( GetActivePane( &nActiveRow, &nActiveCol ) != NULL )
{
if( nActiveRow == _row )
{
if( ++nActiveRow >= m_nRows )
nActiveRow = 0;
SetActivePane( nActiveRow, nActiveCol );
}
} // hide all nRow panes.
int nCol;
for ( nCol = 0; nCol < m_nCols; ++nCol )
{
CWnd* pPaneHide = GetPane( _row, nCol );
ASSERT( pPaneHide != NULL ); pPaneHide->ShowWindow( SW_HIDE );
pPaneHide->SetDlgCtrlID( AFX_IDW_PANE_FIRST + nCol * 16 + m_nRows ); int nRow;
for ( nRow = _row+1; nRow < m_nRows; ++nRow )//下一行的ID设置为上一行的
{
CWnd* pPane = GetPane( nRow, nCol );
ASSERT( pPane != NULL ); pPane->SetDlgCtrlID( IdFromRowCol( nRow-1, nCol ));
}
} m_nRows--;
m_pRowInfo[m_nRows].nCurSize = m_pRowInfo[_row].nCurSize; //
RecalcLayout();
}
void CMySplitterWnd::ReplaceView(int row, int col, CRuntimeClass* pNewClass)//替换View
{
CView *pOldView=(CView*)GetPane(0,0);
ASSERT(*pOldView); int ID=pOldView->GetDlgCtrlID();
CDocument *pDoc=pOldView->GetDocument();
CCreateContext context;
context.m_pCurrentDoc=pDoc;
context.m_pNewViewClass=pNewClass;
context.m_pNewDocTemplate=pDoc?pDoc->GetDocTemplate():NULL;
context.m_pCurrentFrame=NULL;
context.m_pLastView=NULL; CWnd *pWnd;
pWnd=(CWnd*)context.m_pNewViewClass->CreateObject(); ASSERT_KINDOF(CWnd, pWnd);
ASSERT(pWnd->m_hWnd == NULL); // not yet created.
if(!pWnd->Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,ID,&context))
{
TRACE0( "Warning: couldn't create new view.\n" );
// pWnd will be cleaned up by PostNcDestroy
return ;
}
pOldView->ShowWindow(SW_HIDE);
pOldView->SetDlgCtrlID(0); RecalcLayout(); CView *pNewView=DYNAMIC_DOWNCAST(CView,GetPane(row,col) );
ASSERT_KINDOF(CView,pNewView);
pNewView->OnInitialUpdate();
}