问题虽小,难度很大?MFC 打开系统对话框可以使其居中吗?
时间:2011-12-28
来源:互联网
背景: vs2005/2008 MFC 应用程序开发 。C++
开发一个应用程序,在有些功能上发现通过dos 命令调用windows 自带的设置窗口较好。
所以就在应用程序窗口上增加了按钮,通过执行下面的语句 命令打开系统窗口。
C/C++ code
问题:
发现1、打开的窗口不居中? 我想将其居中且在我的父窗口没关闭的情况下,其始终在桌面的
最前面?
各位高手: 能指导一二吗?
感激。
开发一个应用程序,在有些功能上发现通过dos 命令调用windows 自带的设置窗口较好。
所以就在应用程序窗口上增加了按钮,通过执行下面的语句 命令打开系统窗口。
C/C++ code
ShellExecute(NULL, NULL, L"desk.cpl", NULL, NULL, SW_SHOW); //打开windows 自带的系统设置窗口。cmd-> dest.cpl 打开可查看
问题:
发现1、打开的窗口不居中? 我想将其居中且在我的父窗口没关闭的情况下,其始终在桌面的
最前面?
各位高手: 能指导一二吗?
感激。
作者: zhchongyao 发布时间: 2011-12-28
坐等结帖......
作者: zhchongyao 发布时间: 2011-12-28
貌似Widnows自己打开的时候都不是固定位置的,观望中。。。
作者: vichal 发布时间: 2011-12-28
MoveWindow
The MoveWindow function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.
BOOL MoveWindow(
HWND hWnd, // handle to window
int X, // horizontal position
int Y, // vertical position
int nWidth, // width
int nHeight, // height
BOOL bRepaint // repaint flag
);
Parameters
hWnd
Handle to the window.
X
Specifies the new position of the left side of the window.
Y
Specifies the new position of the top of the window.
nWidth
Specifies the new width of the window.
nHeight
Specifies the new height of the window.
bRepaint
Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives aWM_PAINT message. If the parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of moving a child window. If this parameter is FALSE, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, callGetLastError.
Remarks
If the bRepaint parameter is TRUE, the system sends the WM_PAINT message to the window procedure immediately after moving the window (that is, the MoveWindow function calls the UpdateWindow function). If bRepaint is FALSE, the system places the WM_PAINT message in the message queue associated with the window. The message loop dispatches the WM_PAINT message only after dispatching all other messages in the queue.
MoveWindow sends WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED, WM_MOVE, WM_SIZE, and WM_NCCALCSIZE messages to the window.
The MoveWindow function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.
BOOL MoveWindow(
HWND hWnd, // handle to window
int X, // horizontal position
int Y, // vertical position
int nWidth, // width
int nHeight, // height
BOOL bRepaint // repaint flag
);
Parameters
hWnd
Handle to the window.
X
Specifies the new position of the left side of the window.
Y
Specifies the new position of the top of the window.
nWidth
Specifies the new width of the window.
nHeight
Specifies the new height of the window.
bRepaint
Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives aWM_PAINT message. If the parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of moving a child window. If this parameter is FALSE, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, callGetLastError.
Remarks
If the bRepaint parameter is TRUE, the system sends the WM_PAINT message to the window procedure immediately after moving the window (that is, the MoveWindow function calls the UpdateWindow function). If bRepaint is FALSE, the system places the WM_PAINT message in the message queue associated with the window. The message loop dispatches the WM_PAINT message only after dispatching all other messages in the queue.
MoveWindow sends WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED, WM_MOVE, WM_SIZE, and WM_NCCALCSIZE messages to the window.
作者: zhao4zhong1 发布时间: 2011-12-28
被3楼真相了~~!!
作者: cobra_chen 发布时间: 2011-12-28
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28