MFC WYSIWYG editor - visual-studio

I want to make an application in Visual C++ 2012 using MFC frameworks using Document/View structure; I want edit my view (that is the main window) with an editor, not handcoding, but Visual Studio seems that can edit in WYSIWYG mode just dialog boxes; I don't want to make a 'dialog based application', I want to make a Document/View application and edit my View with an editor WYSIWYG; Any solution?

You need to use CFormView as a base class when you creating your MFC application.
If you already have a project, then add a new form using the class wizard. Select CFormView as a base class.
When you open Resource View your new form will be listed in "Dialog" folder

In the last step of the wizard that creates a new document/view application, change the view base class from CView to CFormView. When you do that the CFormView can be edited just like a dialog.

MFC based apps have a WYSIWYG editor. Open the Resource Files folder of your dialog, SDI or MDI project and then open the .rc file. Menus and a toolbox should open up ready for editing.

Related

How do I modify the "Add" sub menu items in solution explorer?

How can I modify the items that appear in the solution explorer "Add" context sub menu? Currently there is New Item, Existing Item, New Folder, then Windows Form, User Control, then Component and Class. I especially want to get rid of the 2 WinForms items and replace them with their WPF counterparts. How do I do that in the easiest way?
You can modify the Add sub menu you get when you right click on a project item from the Tools->Customize... menu:
click on the Commands tab
pick the 'Context Menu' radio button
select Project and Solution Context Menus | Project | Add from the combo box
From here you can modify the context menu.
This is not, however, what you want to do in your particular case.
The WPF commands you want are already in that context menu; you'll see WPF commands like "Add Window" and "Add Page" already present in the Customize dialog if you go through the instructions above. The reason that you don't see them in the actual context menu is because Visual Studio is trying to be smart and it thinks that you're developing a WinForms app and not a WPF app. If it thought this was a WPF app, you wouldn't see the windows forms option (and the user control option would create a WPF user control).
In order to correct visual studio's incorrect assumption, you could make a new project - make sure you pick that you want a WPF app - and add all of your existing files, or you can edit your .csproj file: see my answer to this SO question.

How do I open a Visual Studio project in design view?

I saved my project, but now I can't open it up in design view where you see all the buttons and stuff. Visual Studio 2012
Anyone know how?
You can double click directly on the .cs file representing your form in the Solution Explorer :
This will open Form1.cs [Design], which contains the drag&drop controls.
If you are directly in the code behind (The file named Form1.cs, without "[Design]"), you can press Shift + F7 (or only F7 depending on the project type) instead to open it.
From the design view, you can switch back to the Code Behind by pressing F7.
My problem, it showed an error called "The class Form1 can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again. ". So I moved the Form class to the first one and it worked. :)
From the Solution Explorer window select your form, right-click, click on View Designer. Voila! The form should display.
Click on the form in the Solution Explorer
Just Shift+f7 and Design view will open
OR
Right-click on your form file and Click on View Designer
I had this problem in Visual Studio 2019 today. When I right-clicked a form or user control in Solution Explorer, there was no "View Designer Shift-F7" option. The "View Code F7" option was there, but not the Shift-F7 option. I noticed that I could view and work on the design view for two forms, that I opened before the problem surfaced. But Visual Studio would not let me open more design views.
My solution is: In another project, in the same solution, I created a new Windows Form. Now the "View Designer Shift-F7" is visible and working for all forms and user controls, in all projects in my solution. I deleted the latest new form, and Design View still works. This solved the problem for me.
#Pierre's answer is not always applicable. When I messed up the files in the solution folder a bit (maybe add some code from outside which conflicts the GUI, I don't know precisely), then the Design View does not show up. In fact, my "Solution Explorer" is actually "Solution Explorer - Folder View". There is no object hierachy shown in the Solution Explorer, but just a file & folder view.

DLGTEMPLATE gui editor as a library or a component

I'm looking for a Windows (pure DLGTEMPLATE output no .net resources!) dialog template editor (as a library or component) that can be used to modify or/and create new dialog templates for DialogBoxIndirect() function.
Use the Windows resource editor (part of Visual Studio) to create your dialog, then you can simply load the dialog resource to show the dialog.
You could also write some utility that reads the generated resource dialog and generate the DLGTEMPLATE data for it (I don't think it's that hard).

VS 2008 Windows Forms make "View Code" the default for UserControls

We have some UserControls that can not be designed. So the Windows Forms Designer in VS 2008 is pretty much useless and it takes some time until the designer throws the exception when accidentally doubleclicking the UserControl in the solution explorer. Is there a way I can make the designer open the C# code view when doubleclicking on a UserControl file?
I set up all of my forms to open in code view by default by right clicking on one, and selecting the "Open With..." option. From the dialog that appears, select the "CSharp Editor" option and click the "Set as Default" button, then "OK".
You can do the same with user controls, and other types too.
If you want to control this on a file by file basis, add the following attribute to your controls that you want to open in the source code editor:
[System.ComponentModel.DesignerCategory("")]
public class MyControl : Control
{
}

How do I configure visual studio to use the code view as the default view for Webservices?

When you double click on a class (in 'solution explorer')... if that class happens to be an .asmx.cs webservice... then you get this...
To add components to your class, drag
them from the Toolbox and use
the Properties window to set their
properties. To create methods and
events for your class, click here
to switch to code view.
...it's a 'visual design surface' for webservices.
(Who actually uses that surface to write webservices?)
So what I want to know, how do I configure visual studio to never show me that design view?
Or at least, to show me the code view by default?
You can set the default editor for any given file type (.cs, .xml, .xsd, etc). To change the default editor for a given type:
Right-click a file of that type in
your project, and select "Open
With..."
Select your preferred editor. You
may want "CSharp Editor".
Click "Set as Default".
I don't see the behavior you see with web services, but this should work with all file types in Visual Studio.
Add the following attribute to your class:
[System.ComponentModel.DesignerCategory("Code")]
(Not sure why [System.ComponentModel.DesignerCategory("")] does not work.)
Add the following attribute to your class:
<System.ComponentModel.DesignerCategory("")>

Resources