posts - 19,  comments - 21,  trackbacks - 0
昨天写了MoveWindow函数,今天又要写SetWindowPos函数,因为MoveWindow确实不好,浪费了差不多一天时间。。。对于主窗口,选择了Center属性就可以移动位置,不选就不行;窗口资源过大也不能移动;改变后窗口的尺寸大于等于屏幕尺寸的话,在它上面DoModal出来的新窗口不能移动。。原来,使用MoveWindow移动对话框位置似乎有很苛刻的条件,一不小心就原地不动了,而且我也实在琢磨不透这样的条件,网上也没有查处来。今天用了SetWindowPos后,才发现,果然好用!

BOOL SetWindowPos(
   
const CWnd* pWndInsertAfter,
   
int x,
   
int y,
   
int cx,
   
int cy,
   UINT nFlags 
);

Parameters

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.
nFlags
Specifies sizing and positioning options. This parameter can be a combination of the following: 常用的是SWP_SHOWWINDOW

注意:
    这里的坐标参数用的是Client坐标,对于子窗口用的是其父窗口的坐标系。然而对于用DoModal()弹出的窗口,如果在资源属性里没有选择Child属性的话,它的父窗口是DeskTop,而不是调用DoModal()的窗口。

posted on 2006-03-01 17:30 halCode 阅读(2637) 评论(0)  编辑 收藏 引用 所属分类: VC/MFC

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2006年3月>
2627281234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(7)

随笔分类

随笔档案

文章分类

文章档案

相册

编程资源

不务正业

找工作

搜索

  •  

最新评论

阅读排行榜

评论排行榜