急问 有关SetWindowPos这个API函数

xueshi 2006-10-10 11:09:51
有关定位的问题

这个函数的位置 是指相对于屏幕的坐标 对吗?

可是我想 让一个子窗口 相对于父窗口实现定位怎么办?

比如坐标(100,100) 我想让子窗口 相对于父窗口的左上角的坐标是(100,100)

pDialog->SetWindowPos(NULL, 11, 66, 440, 290, SWP_NOZORDER);

第一个参数要填写this?

分数不多了 请教
...全文
193 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
raymonzhao 2006-10-10
  • 打赏
  • 举报
回复
第一个参数是要改变窗口的ZORDER时填的.如果你只是移动位置的话就填空.这里要传的坐标应该就是相对坐标的.
SetWindowPos(NULL,100,100,宽,高,....)
pomelowu 2006-10-10
  • 打赏
  • 举报
回复
pWndInsertAfter
Identifies the CWnd object that will precede this CWnd object in the Z-order. This parameter can be a pointer to a CWnd or a Pointer to one of the following values:

wndBottom Places the window at the bottom of the Z-order. If this CWnd is a topmost window, the window loses its topmost status; the system places the window at the bottom of all other windows.

wndTop Places the window at the top of the Z-order.

wndTopMost Places the window above all nontopmost windows. The window maintains its topmost position even when it is deactivated.

wndNoTopMost Repositions the window to the top of all nontopmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a nontopmost window.

Windows are ordered on the screen according to their Z-order; the window at the top of the Z-order appears on top of all other windows in the order.

All coordinates for child windows are client coordinates (relative to the upper-left corner of the parent window's client area).

A window can be moved to the top of the Z-order either by setting the pWndInsertAfter parameter to &wndTopMost and ensuring that the SWP_NOZORDER flag is not set or by setting a window's Z-order so that it is above any existing topmost windows. When a nontopmost window is made topmost, its owned windows are also made topmost. Its owners are not changed.

A topmost window is no longer topmost if it is repositioned to the bottom (&wndBottom) of the Z-order or after any nontopmost window. When a topmost window is made nontopmost, all of its owners and its owned windows are also made nontopmost windows.

If neither SWP_NOACTIVATE nor SWP_NOZORDER is specified (that is, when the application requests that a window be simultaneously activated and placed in the specified Z-order), the value specified in pWndInsertAfter is used only in the following circumstances:

Neither &wndTopMost nor &wndNoTopMost is specified in the pWndInsertAfter parameter.

This window is not the active window.

An application cannot activate an inactive window without also bringing it to the top of the Z-order. Applications can change the Z-order of an activated window without restrictions.

A nontopmost window may own a topmost window, but not vice versa. Any window (for example, a dialog box) owned by a topmost window is itself made a topmost window to ensure that all owned windows stay above their owner.

With Windows versions 3.1 and later, windows can be moved to the top of the Z-order and locked there by setting their WS_EX_TOPMOST styles. Such a topmost window maintains its topmost position even when deactivated. For example, selecting the WinHelp Always On Top command makes the Help window topmost, and it then remains visible when you return to your application.

To create a topmost window, call SetWindowPos with the pWndInsertAfter parameter equal to &wndTopMost, or set the WS_EX_TOPMOST style when you create the window.

If the Z-order contains any windows with the WS_EX_TOPMOST style, a window moved with the &wndTopMost value is placed at the top of all nontopmost windows, but below any topmost windows. When an application activates an inactive window without the WS_EX_TOPMOST bit, the window is moved above all nontopmost windows but below any topmost windows.

If SetWindowPos is called when the pWndInsertAfter parameter is &wndBottom and CWnd is a topmost window, the window loses its topmost status (WS_EX_TOPMOST is cleared), and the system places the window at the bottom of the Z-order.
raymonzhao 2006-10-10
  • 打赏
  • 举报
回复
你查下帮助.如果是绝对坐标的话,你就把100.100CLIENTTOSCREEN一下.
xueshi 2006-10-10
  • 打赏
  • 举报
回复
我是填写的(100,100)

可是 显示的时候 是按照绝对坐标显示的

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧