可使用函数1:
//可用于更改窗口的大小,位置等
BOOL SetWindowPos(
const CWnd* pWndInsertAfter,
int x,
int y,
int cx,
int cy,
UINT nFlags
);
可使用函数2:
//可用于更改窗口的位置,大小
void MoveWindow(
int x,
int y,
int nWidth,
int nHeight,
BOOL bRepaint = TRUE
);
void MoveWindow(
LPCRECT lpRect,
BOOL bRepaint = TRUE
);
项目类型:基于对话框的mfc应用程序
可在函数
//当收到WM_INITDIALOG消息时此函数被调用
virtual BOOL OnInitDialog( );
中加上以上两个函数中的一个并给予适当的参数,就可改变对话框窗口的大小
例如下面的代码,
//将对话框置顶,不改变对话框位置,将对话框大小设置为485x299
BOOL CdialogDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
SetWindowPos(&wndTop,0,0,485,299,SWP_NOMOVE);
return TRUE; // return TRUE unless you set the focus to a control
}
就可以将对话框大小设置为485x299,也可使用函数MoveWindow达到同样的效果,代码如下
//将对话框置于屏幕中心,设置对话框的大小为485x299
BOOL CdialogDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
SetWindowPos(&wndTop,0,0,485,299,SWP_NOMOVE);
return TRUE; // return TRUE unless you set the focus to a control
}
略注:项目类型不同,函数的使用位置或者设置方法可能不同.函数的具体使用方法和各参数的含义可以参见msdn.
以上内容属于个人理解,仅供参考,不保证正确. 如果发现错误或有建议请与我联系,谢谢.
email: linjieligc@qq.com
qq:914196158
程序设计交流群:250967270
Citius, Altius, Fortius