cs.style &=~WS_MAXIMIZEBOX; cs.style &=~FWS_ADDTOTITLE; cs.style &=~WS_THICKFRAME; cs.style |=WS_DLGFRAME; int cxScreen=::GetSystemMetrics(SM_CXSCREEN); int cyScreen=::GetSystemMetrics(SM_CYSCREEN); cs.x=0; cs.y=0; cs.cx=cxScreen; cs.cy=cyScreen;
if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; //TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE;这是修改后的函数
调整这个可以。
要控制一个框架的的最大最小尺寸,你需要做两件事情.在CFrameWnd的继承类中
处理消息WM_GETMINMAXINFO,结构MINMAXINFO设置了整个窗口类的限制,因此记
住要考虑工具条,卷动条等等的大小.// 最大最小尺寸的象素点 - 示例
#define MINX 200
#define MINY 300
#define MAXX 300
#define MAXY 400void CMyFrameWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
CRect rectWindow;
GetWindowRect(&rectWindow); CRect rectClient;
GetClientRect(&rectClient); // get offset of toolbars, scrollbars, etc.
int nWidthOffset = rectWindow.Width() - rectClient.Width();
int nHeightOffset = rectWindow.Height() - rectClient.Height(); lpMMI->ptMinTrackSize.x = MINX + nWidthOffset;
lpMMI->ptMinTrackSize.y = MINY + nHeightOffset;
lpMMI->ptMaxTrackSize.x = MAXX + nWidthOffset;
lpMMI->ptMaxTrackSize.y = MAXY + nHeightOffset;
}
第二步,在CFrameWnd的继承类的PreCreateWindow函数中去掉WS_MAXIMIZEBOX消
息,否则在最大化时你将得不到预料的结果.BOOL CMyFrameWnd::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~WS_MAXIMIZEBOX;
return CFrameWnd::PreCreateWindow(cs);
}
cs.style &=~FWS_ADDTOTITLE;
cs.style &=~WS_THICKFRAME;
cs.style |=WS_DLGFRAME; int cxScreen=::GetSystemMetrics(SM_CXSCREEN);
int cyScreen=::GetSystemMetrics(SM_CYSCREEN);
cs.x=0;
cs.y=0;
cs.cx=cxScreen;
cs.cy=cyScreen;
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
//TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs return TRUE;这是修改后的函数
SetWindowPos(Winhandle,HWND_TOP,0,0,WinWidth,WinHight,SWP_SHOWWINDOW|SWP_NOREPOSITION);