How to save the Z-order control in the MFC dialog?

he starts to deceive me, but I canโ€™t understand how to keep the position of child control in z-order. During development, in the MFC dialog resource editor, I have STATIC control (a descendant of CStatic) at the bottom (tab order Nr.1), i.e. it is overlapped by other controls, such as buttons, list, etc.

At run time, the dialog processes the WM_TIMER message, and the STATIC control moves in the OnTimer handler:

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

After calling SetWindowPos for the sublimated CStatic control, it displayed the other controls in the dialog box, regardless of what I pass in the first argument.

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

+4
source share
1 answer

The answer is simple. I just missed one flag in the SetWindowPos documentation. To prevent z-order changes, just go to SWP_NOZORDER , so the function call should look like this:

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

Source: https://habr.com/ru/post/1385651/


All Articles