如何在 mfc 中将控件置于最前面
在设计时如何在 MFC 中更改控件的 Z 顺序 - 即我不能使用 SetWindowPos 或在运行时执行此操作 - 我想在设计器中查看更改后的 z 顺序(即使我不得不求助于直接编辑 .rc 代码).
How do you change controls' Z-order in MFC at design time - i.e. I can't use SetWindowPos or do this at runtime - I want to see the changed z-order in the designer (even if I have to resort to direct-editing the .rc code).
我有一个要向其中添加控件的 MFC 对话框.如果控件的边缘之间有重叠,我想将一个放在另一个的前面.在 Windows 窗体或 WPF 等中.我可以放在前面、放在后面、放在前面、放在后面.我在 MFC 中找不到这些选项,也无法确定它如何确定前面的内容,因为刚刚添加的控件通常位于之前存在的控件后面.如何在 MFC 中操作 Z 顺序?即使我必须直接操作 .rc 文件代码(即围绕设计器结束运行).
I have an MFC dialog to which I am adding controls. If there is overlap between the edges of the controls, I want to bring one to the front of the other. In Windows Forms or WPF, etc. I can Bring to Front, Send to Back, Bring Forward, Send Back. I don't find these options in MFC, nor can I tell how it determines what is in front, as a control just added is often behind a control that was there previously. How can I manipulate the Z-order in MFC? Even if I have to manipulate the .rc file code directly (i.e. end-run around the designer).
推荐答案
我认为前面的控件会是rc文件中最后出现的控件.换句话说,对话框编辑器将在 rc 文件中从上到下绘制每个遇到的控件,并在必要时将它们重叠.
I think the control in front will be the last control that occurs in the rc file. In other words, the dialog editor will draw each control as it is encountered from top to bottom in the rc file, overlapping them when necessary.
您可以编辑 rc 文件以重新排序它们,或者您可以在编辑器中更改 Tab 键顺序,这样做的效果相同,因为 Tab 键顺序也是根据控件在文件中出现的顺序设置的.据我所知,MFC 没有提供任何其他在设计时对重叠控件进行分层的方式.
You can edit the rc file to reorder them, or you can change the tab order in the editor, which does the same thing since tab order is also set based on the order that the controls occur in the file. To my knowledge MFC doesn't offer any other way of layering overlapping controls at design time.
相关文章