由Create一个Child窗口,导出的z序问题

13 篇文章 0 订阅

首先遇到的情况,直接看图

看到这现象有点怀疑人生,Windows默认Create顺序是按照Z序依次递增的,然而为何会出现如此现象?

首先和窗口类型确实有关:用的是Child,如果使用popup/overlapped都正常,我们通常非模态对话框用overlapped最多,这次要做子窗口管理,才发现有如此问题。考虑在窗口类型上选择:层叠/弹出/子窗口。选择Child类型是必须的(根据需求)。于是想办法改变窗口Z序,windowsZ序说明并不多,看来也是不复杂的原因,搜索相关函数

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

Identifies the CWnd object that will precede (be higher than) 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 non-topmost windows. *重点The window maintains its topmost position even when it is deactivated*.

  • wndNoTopMost   Repositions the window to the top of all non-topmost windows (that is, behind all topmost windows). *重点This flag has no effect if the window is already a non-topmost window*.

换句话说,就此4中Z序:底部/顶部/最顶/非最顶,这都是相对你要插入的窗口指针的

看微软注释:

 static AFX_DATA const CWnd wndTop; // SetWindowPos's pWndInsertAfter
 static AFX_DATA const CWnd wndBottom; // SetWindowPos's pWndInsertAfter
 static AFX_DATA const CWnd wndTopMost; // SetWindowPos pWndInsertAfter
 static AFX_DATA const CWnd wndNoTopMost; // SetWindowPos pWndInsertAfter



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值