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中的控制的z顺序-也就是说,我不能使用SetWindowPos或者在运行时这样做-我想在设计器中看到更改的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).
我有一个MFC对话框,我正在添加控件。如果在控件的边缘之间有重叠,我想把一个放到另一个的前面。在Windows窗体或WPF中,我可以把它带到前面,发送回来,提出,送回。我在MFC中没有找到这些选项,我也不知道它是如何决定前面的内容的,因为刚刚添加的控件通常是在之前的控件的后面。在MFC中如何操作z顺序?即使我必须直接操作.rc文件代码(即围绕设计器的最终运行)。
7 个解决方案
#1
14
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文件中最后一个控件。换句话说,对话框编辑器将在rc文件中从上到下显示每个控件,在必要时将它们重叠。
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.
您可以编辑rc文件来重新排序它们,或者您可以更改编辑器中的选项卡顺序,因为根据控件在文件中出现的顺序,也可以进行相同的操作。据我所知,MFC在设计时不提供任何其他的分层重叠控制方式。
#2
18
In Visual Studio 6.0 do the following.
在Visual Studio 6.0中执行以下操作。
Open the dialog screen (in designer view)
打开对话框(在designer视图中)
Press Ctrl + D
按Ctrl + D
The tab orders will be shown for each control
每个控件将显示标签命令。
Start clicking controls in the tab order you expect to see in run-time (ie., the control on which you click first will have tab order set to 1 and so on...)
在您希望在运行时看到的选项卡顺序中开始单击控件。,首先单击的控件将有选项卡顺序设置为1,以此类推……
#3
10
GetDlgItem(IDC_MYCONTROL)->SetWindowPos(HWND_TOP,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
#4
6
Actually, if you want to do this in the resource editor, you can just cut the item and then paste it back as a quick and dirty solution. Just Ctrl-X then Ctrl-V.
实际上,如果您想在资源编辑器中这样做,您可以将该项目剪切,然后将其粘贴到一个快速且不干净的解决方案中。只是Ctrl-X然后ctrl - v。
Editing the RC file will also work.
编辑RC文件也可以工作。
#5
1
You can use CWnd::SetWindowPos() to control the Z order of your controls, without changing their position in the parent window.
您可以使用CWnd::SetWindowPos()来控制控件的Z顺序,而不会改变它们在父窗口中的位置。
#6
1
GetDlgItem(IDC_CONTROL1)->SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
#7
0
In the MSVC 2005 dialog resource editor there is an option to set the tab order. In MSVC 2005 it is found on the Format, Tab Order menu.
在MSVC 2005对话资源编辑器中,有一个选项来设置选项卡顺序。在MSVC 2005中,它被发现在格式,标签菜单。
The tab order displayed by this menu option is the same order in which the controls are written to the resource file.
此菜单选项显示的选项卡顺序与将控件写入资源文件的顺序相同。
#1
14
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文件中最后一个控件。换句话说,对话框编辑器将在rc文件中从上到下显示每个控件,在必要时将它们重叠。
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.
您可以编辑rc文件来重新排序它们,或者您可以更改编辑器中的选项卡顺序,因为根据控件在文件中出现的顺序,也可以进行相同的操作。据我所知,MFC在设计时不提供任何其他的分层重叠控制方式。
#2
18
In Visual Studio 6.0 do the following.
在Visual Studio 6.0中执行以下操作。
Open the dialog screen (in designer view)
打开对话框(在designer视图中)
Press Ctrl + D
按Ctrl + D
The tab orders will be shown for each control
每个控件将显示标签命令。
Start clicking controls in the tab order you expect to see in run-time (ie., the control on which you click first will have tab order set to 1 and so on...)
在您希望在运行时看到的选项卡顺序中开始单击控件。,首先单击的控件将有选项卡顺序设置为1,以此类推……
#3
10
GetDlgItem(IDC_MYCONTROL)->SetWindowPos(HWND_TOP,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
#4
6
Actually, if you want to do this in the resource editor, you can just cut the item and then paste it back as a quick and dirty solution. Just Ctrl-X then Ctrl-V.
实际上,如果您想在资源编辑器中这样做,您可以将该项目剪切,然后将其粘贴到一个快速且不干净的解决方案中。只是Ctrl-X然后ctrl - v。
Editing the RC file will also work.
编辑RC文件也可以工作。
#5
1
You can use CWnd::SetWindowPos() to control the Z order of your controls, without changing their position in the parent window.
您可以使用CWnd::SetWindowPos()来控制控件的Z顺序,而不会改变它们在父窗口中的位置。
#6
1
GetDlgItem(IDC_CONTROL1)->SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
#7
0
In the MSVC 2005 dialog resource editor there is an option to set the tab order. In MSVC 2005 it is found on the Format, Tab Order menu.
在MSVC 2005对话资源编辑器中,有一个选项来设置选项卡顺序。在MSVC 2005中,它被发现在格式,标签菜单。
The tab order displayed by this menu option is the same order in which the controls are written to the resource file.
此菜单选项显示的选项卡顺序与将控件写入资源文件的顺序相同。