▲进入窗口时最大化
只需要在MainFrame中的ActivateFrame中加入以下一句:
void CMainFrame::ActivateFrame(int nCmdShow) { // TODO: Add your specialized code here and/or call the base class //初始最大化 nCmdShow=SW_SHOWMAXIMIZED; CFrameWnd::ActivateFrame(nCmdShow); }
▲窗口自适应屏幕大小:
void CVMSServerView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: Add your message handler code here //根据窗口大小自适应 CWnd *pWnd; pWnd = GetDlgItem(IDC_TREE_DEVICE); if(pWnd!=0 && nType==0) { int j=0; iWidth=cx; iHeight=cy; GetWindowRect(rcCus); m_ctlTree.MoveWindow(0,0,0.2*iWidth,iHeight); switch(iWinCounts) { case 1: m_outPut[0].MoveWindow(0.2*iWidth+rcCus.left+2,rcCus.top+2,0.8*iWidth,iHeight); break; case 4: for(j;j<iWinCounts;j++) { m_outPut[j].MoveWindow(0.2*iWidth+rcCus.left+2+j%2*0.4*iWidth,rcCus.top+2+j/2*iHeight/2,0.8*iWidth/2,iHeight/2); } break; case 9: for(j;j<iWinCounts;j++) { m_outPut[j].MoveWindow(0.2*iWidth+rcCus.left+2+j%3*0.8*iWidth/3,rcCus.top+2+j/3*iHeight/3,0.8*iWidth/3,iHeight/3); } break; case 16: for(j;j<iWinCounts;j++) { m_outPut[j].MoveWindow(0.2*iWidth+rcCus.left+2+j%4*0.8*iWidth/4,rcCus.top+2+j/4*iHeight/4,0.8*iWidth/4,iHeight/4); } break; default: break; } } }