问题描述
我是.NET程序员.我从来没有在MFC中开发任何东西.目前,我必须为某些图像处理任务编写一个C ++应用程序(控制台).我写完了.但是关键是我还需要为此设计GUI.好吧,不会有什么复杂的事情.只是一个带有几个按钮,单选按钮,复选框,PictureBox和&的窗口几个滑块.而已.
I'm a .NET programmer. I've never developed anything in MFC. Currently I had to write a C++ application (console) for some image processing task. I finished writing it. But the point is I need to design GUI also for this. Well, there won't be anything complex. Just a window with few Buttons, RadioButtons, Check Boxes, PicturesBox & few sliders. thats it.
我正在使用VS 2008,期待使用.NET样式的表单设计器.
I'm using VS 2008 and was expecting a .NET style form designer.
为了测试,我创建了一个MFC项目(具有所有默认配置),并且这些文件是默认创建的:
Just to test, I created a MFC project (with all default configuration) and these files were created by default:
ChildFrm.cpp
MainFrm.cpp
mfc.cpp
mfcDoc.cpp
mfcView.cpp
stdafx.cpp
现在,我找不到Designer
.没有视图">设计器".我已经打开了上面所有的* .cpp文件,并在代码编辑器中右键单击以查看"Designer View". ToolBox只是空的,因为我处于代码编辑器模式.
Now, I'm unable to find a Designer
. There is no View > Designer. I've opened all the above *.cpp and in the code editor right clicked to see "Designer View". ToolBox is just empty because I'm in code editor mode.
如何打开设计师?
推荐答案
此扩展了Alex Farber的回答,该回答基本上是正确的,但有些不完整.
This expands on Alex Farber's answer, which is basically correct but somewhat incomplete.
首次创建应用程序时,您可以选择一种应用程序类型:
When you're first creating your application, you get to select an application type:
如您所见,Application type
的默认选择是多个文档",但紧随其后的是基于对话框".选择该选项将产生一个应用程序,该应用程序的主窗口(默认情况下)具有一个确定"按钮和一个取消"按钮(以及一个静态控件,其内容类似于在此处添加控件").创建完应用程序后,可以添加更多控件以使其执行有用的操作.对于寿命相对较短的应用程序,这往往是最好的选择-即,打开它们,填写一些字段,然后单击确定"(或取消")再次关闭它们.它也可以在其他情况下使用,但这确实是它的主要优势.
As you can see, the default selection for the Application type
is "Multiple Documents", but just below that is "Dialog Based". Selecting that will produce an application whose main window (by default) has an "Ok" button and a "Cancel" button (and a static control that says something like "add controls here"). When you finish creating the application, you can add more controls to get it to do something useful. That tends to work best for applications that are relatively short-lived -- i.e., you open them, fill in a few fields, and click "Ok" (or "Cancel") to close them again. It can work for other scenarios as well, but that's really its primary strength.
对于更像是典型的.NET应用程序,具有常规菜单等功能以及将控件放置在窗口表面上的功能,通常会在此处选择单个应用程序",但是当您进入生成的类"屏幕:
For something more like a typical .NET application, with a normal menu and such, but also the ability to place controls on the window's surface, you'd typically select "Single Application" here, but when you get to the "Generated Classes" screen:
在视图类的基类的下拉列表中,您需要将默认的CView
的选择更改为CFormView
.这给了您一种组合:您的应用程序总体上是基于Document/View体系结构的,但是您的View类基本上就像一个对话框,因此可以承载控件.当您单击完成"按钮时,它会警告您打印支持将不可用.假设您同意这一点,那么它将创建您的应用程序.要编辑窗口的表单(与要查找的Designer相同的一般顺序),您将在左侧的工具窗口中找到资源视图",然后在对话框列表中打开该表单:
In the drop-down list for the base class of your View Class, you need to change the selection for the default CView
to CFormView
. This gives you kind of a combination: your application as a whole is based on the Document/View architecture, but your View class basically acts like a dialog, so it can host controls. When you click the "Finish" button, it'll warn you that Printing support won't be available. Assuming you agree to that, it'll then create your application. To edit the form for your window (on the same general order as the Designer you're looking for), you'll in the tool window on the left for the "Resource View", and open the form in the list of dialogs:
再次打开该对话框,您可以使用对话框编辑器将控件等放置在表单上:
Opening that will (again) let you use the dialog editor to put controls and such on your form:
总结:MFC为您提供了更多选择.这些选择中的一种(或两种)非常接近于您对.NET/WinForms的习惯.其他选项则大不相同-碰巧的是,默认选项属于不同"类别.
To summarize: MFC gives you quite a few more choices. One (or, sort of, two) of those choices correspond fairly closely to what you're accustomed to with .NET/WinForms. Others are quite different -- and as it happens, the default choices fall into the "different" category.
这篇关于是否有Visual Studio中MFC的设计器,如.NET中的Windows窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!