Is there a Designer for MFC in Visual Studio like for windows forms in .NET?

后端 未结 3 2024
天涯浪人
天涯浪人 2021-02-02 08:40

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 th

相关标签:
3条回答
  • 2021-02-02 09:09

    Look here. It's not like the forms designer, but should get you started.

    0 讨论(0)
  • 2021-02-02 09:23

    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:

    alt text

    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:

    alt text

    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:

    alt text

    Opening that will (again) let you use the dialog editor to put controls and such on your form:

    alt text

    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.

    0 讨论(0)
  • 2021-02-02 09:28

    Win32 dialog designer is available for dialogs. Create new project, selecting "Dialog-based application" on the Application Type Wizard step. When project is created, open Resource View, expand Dialogs node, double-click main dialog, and dialog designer is open.

    For MDI/SDI applications, as you have created, you can select CFormView as base class on one of Wizard steps. This creates a dialog embedded to frame, designer is available in the Resource view.

    Also, for every Win32/MFC application, you can add new dialog (not main window) from Resource View.

    0 讨论(0)
提交回复
热议问题