BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style &= ~FWS_ADDTOTITLE;
//屏蔽“无标题”字样
cs.style &= ~WS_MAXIMIZEBOX;
//屏蔽屏幕最大化
//cs.style &= ~WS_THICKFRAME; //不可改变大小
return TRUE;
}
//调整状态栏大小
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!m_wndStatusBar.Create(
this))
{
TRACE0("未能创建状态栏\n");
return -1;
// 未能创建
}
m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/
sizeof(UINT));
m_wndStatusBar.SetPaneInfo(0,m_wndStatusBar.GetDlgCtrlID(),SBPS_NORMAL,230);
//调整大小
//.
}
//固定MainFrame大小
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
POINT p = {365,400};
lpMMI->ptMaxTrackSize = p;
lpMMI->ptMinTrackSize = p;
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
// MainFrm.h 增加
public:
POINT m_TrackSize;
void SetAutoSize();
// MainFrm.cpp
void CMainFrame::SetAutoSize()
{
CRect rc;
GetWindowRect(&rc);
m_TrackSize = CPoint(rc.Width(),rc.Height());
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
if (m_TrackSize.x && m_TrackSize.x)
{
lpMMI->ptMinTrackSize = m_TrackSize;
lpMMI->ptMaxTrackSize = m_TrackSize;
}
CXTPFrameWnd::OnGetMinMaxInfo(lpMMI);
}
// OppoTest6View.cpp
void COppoTest6View::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
CMainFrame* MainFrame = (CMainFrame*)GetParentFrame();
MainFrame->SetAutoSize();
}