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.
I'm using VS 2008 and was expecting a .NET style form designer.
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
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.
How to open a designer?
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:
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.
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:
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:
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.