zoukankan      html  css  js  c++  java
  • How to keep Z-order of a control in MFC dialog?


    it starts driving me nuts, but I cann't figure out how to keep position of a child control in a z-order. At design time in MFC dialog resource editor I have STATIC control (descendant of CStatic) at the bottom (tab order Nr. 1), ie. it's overlapped by other controls like buttons, listbox etc.

    At runtime, dialog handles WM_TIMER message and in OnTimer handler there gets the STATIC control moved:

    void CTestMFCDlg::OnTimer(UINT_PTR nIDEvent)
    {
      ...
      m_stMyStatic.SetWindowPos(&this->wndBottom, xpos, ypos, 0, 0, SWP_NOSIZE);
      ...
    }

    After the call of SetWindowPos for the sublassed CStatic control, it's drawed over other controls in a dialog, no matter what I'm passing in the first argument.

    Any idea how to keep the control at the bottom of Z-order all the time ?






    The answer is plain simple. I did just overlooked one flag in SetWindowPos documentation. To prevent z-order changing just pass SWP_NOZORDER flag, so the function call should look like:

    m_stMyStatic.SetWindowPos(NULL, xpos, ypos, 0, 0, SWP_NOSIZE | SWP_NOZORDER); 

  • 相关阅读:
    python之os模块
    python之字符串
    python之爬虫(beautifulsoup)
    python之常见算法
    python之装饰器(类装饰器,函数装饰器)
    python之mock使用,基于unittest
    python之定时器
    python基础语法随记
    redis基础
    移动端页面开发(二)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13318526.html
Copyright © 2011-2022 走看看