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); 

  • 相关阅读:
    动态内存有那几个?
    Swift的可选的和可选链
    结构的声明
    指针的理解
    类的初始化分析要点代码
    Swift属性的理解和代码
    swift基本类型
    Swift的下标代码
    Swift枚举代码
    mysql 修改编码格式
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13318526.html
Copyright © 2011-2022 走看看