Create single form application - visual-studio

I need to create very basic single form application in my MS Visual Studio 2019, Visual c++. I prefer to design this form in designer. I create new application in my Visual C++ by selecting new Windows Desktop Application. As result I got main form that I can't design in designer. I prefer to have dialog style based form similar to About form that I can edit in designer as main form. How to achieve that?

I suggest you could try to use MFC to create a form based on dialog style
First of all, you should installed with the Desktop development with C++ workload and the optional Visual C++ MFC for x86 and x64 component.
And then you could create a form based on dialog style.
1,Use the MFC Application Wizard to create a new MFC application. To run the wizard, from the File menu select New, and then select Project. The New Project dialog box will be displayed.
2,In the New Project dialog box, expand the Visual C++ node in the Project types pane and select MFC. Then, in the Templates pane, select MFC Application. Type a name for the project, and click OK.
3,On the Application Type pane,under Application type select Dialog based. click finish, and you have created a form based on dialog style.
For more details I suggest you could refer to the Doc:
https://learn.microsoft.com/en-us/cpp/mfc/reference/creating-an-mfc-application?view=vs-2019

Related

How to publish Windows Forms Control Library with Visual Studio 2022

I believe this is a question for beginners and I apologize if it was not asked in a right way. I use Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.2.2
The steps I take are:
In the Start Window that asks me "What would you like to do?" I select Create a new project. This takes me to a new window "Create a new project".
In the search field(Search for templates (Alt+S)) I enter "Windows Forms Control" and choose first result. The first result for me is: "C# Windows Forms Control Library(.NET Framework) A project for creating controls to use in Windows Forms(WinForms) applications". and then I click Next.
I click Create because for this question a name or anything else is not something that I have changed. That means(for me) that "Place solution and project in the same directory" is unchecked and that I use .NET Framework 4.7.2
After the project is opened I go to the Build option in the menu and look for the "Publish Solution" option but there is none.
Questions:
Is it possible to publish this(Windows Forms Control Library with Visual Studio 2022) or I just use .dll when I am finished ?
If it is not possible to publish or it is not possible to create some kind of executable file from Windows Forms Control Library why I am able to drag and drop controls like buttons and text fields and with that create some kind of UI?
If it is possible to publish please tell me how?
Is there some kind of list what we can publish or not when using visual studio?
Additional explanation: I followed this: https://learn.microsoft.com/en-us/visualstudio/designers/walkthrough-windows-forms-designer?view=vs-2022 and then at the end of this article there is a "Next steps" part where it says:
This article has demonstrated how to construct the user interface for
a simple calculator. To continue, you can extend its functionality by
implementing the calculator logic, then publish the app using
ClickOnce. Or, continue on to a different tutorial where you create a
picture viewer using Windows Forms.
And I followed the article that is behind the link "publish the app using ClickOnce" and tried to publish.
After some research(more than one try...) I have decided to ask a question here...
Thanks for your time in advance.

Visual Studio Installer how to prompt for install of shortcuts

I am using the basic VS project of Other Project Types\Setup and Deployment\Visual Studio Installer\ Setup Project.
I want to give the user the option of whether or not to create a desktop shortcut to the application. I know how to create a desktop shortcut, but not to make it optional. So far I have not made any custom dialogs for the install, just using the standard interface that VS provided automatically.
Is there any way to provide the user the choice without getting into a whole bunch of customization?
Are many people using this installer? I look around, we have a 5 year old license to InstallShield, but I have also found it to be bulky and more than we need for this application.
I also looked at WiX, but I don't have the time to learn an install package right now and it looks like a fair learning curve on it.
Basically our install has .NET 4.0 requirements, installs SQL Server CE, a couple other DLL's which are just copied in and populates a structure. I am not using the registry, using the preferred resources approach for that, so it is a very straightforward install.
There several ways to do it, in general… But I don't know the particular steps for Visual Studio installer project.
Create a feature which contains the Desktop shortcut. If you have feature selection tree in your installer, present this feature as yet anther option.
With another approach, you'll have to customize one of the existing dialogs or add a new one where you can show a checkbox. The checkbox changes the value of a property which, in its turn, controls the installation of component or feature for Desktop shortcut.
Yet I guess this method is not supported by Visual Studio.
See Microsoft UX guidelines on putting shortcuts on Desktop.
In most cases, it is not necessary to put a shortcut on Desktop unless your target users start your application very often.
The general approach is this:
create a custom dialog which contains a control that can condition the shortcut, for example a checkbox
create a custom action which deletes the shortcut after install
condition it with the checkbox property
This can be done in Visual Studio:
select your setup project in Solution Explorer
click User Interface Editor button on top pane in Solution Explorer
add a Checkboxes dialog under Install -> Start
customize it to contain only a checkbox that conditions your shortcut
add your shortcut deletion custom action in Custom Actions Editor page
condition it with the checkbox property
Some commercial setup authoring tools have this feature built-in.

Extending VisualStudio

I want to extend Visual Studio such that, when someone right clicks on Solution Explorer, context menu should have a new menu item, say "Open custom form", clicking which should open a form (this form would actually accept some settings and modify config file accordingly)
Q1. Please provide on where should I start for such extension. Couldn't find any reference/tutorial link :(
Q2. What technology can be used to make such a form - Winforms/WPF?
Either Windows Forms or WPF should be fine.
SO: Visual Studio Add-In - adding a context menu item to solution-explorer
Google Code: explorer-popup-add-in
There's a lot of docs on Visual Studio integration here

Visual Studio - I want "Go To Definition" to open Object Browser, not "metadata"

In Visual Studio version 2002 and 2003 "Go To Definition" would find the selected type or member in the Object Browser. In 2005 onwards it opens a source window "generated from metadata" instead. How do I configure these newer versions to go to Object Browser? (In other words, I have the opposite problem to this one.)
Installing ReSharper makes this change, so I know it must be possible, but how do I do it without ReSharper?
As workaround you can create the following macro:
Sub GoToDefinitionUsingObjectBrowser()
DTE.ExecuteCommand("Edit.SelectCurrentWord")
DTE.ExecuteCommand("View.ObjectBrowser")
DTE.ExecuteCommand("View.ObjectBrowserSearch", DTE.ActiveDocument.Selection.Text)
End Sub
Then go to Tools/Options/Keyboard and assign hot key for this macro.
Tested in Visual Studio 2010.
I believe what re-sharper is doing is doing some hooks on that click event with the Visual Studio SDK I do not think there is any simple menu or location that can change that setting.
Instructions (pulled from CODE Magazine) edited down a bit to the part that pertainst to making the right click menus.
Creating a VSPackage
...The VS SDK installs a few more project
templates in Visual Studio, one of
them being the Visual Studio
Integration Package (Figure 1),
located under Other Project Types >
Extensibility on the New Project
dialog box.
After this standard dialog box, the
Visual Studio Integration Package
Wizard guides you through creating the
new package project:
Select a programming language. The wizard currently supports Visual
C++ and Visual C#. You can create or
pick a key file to sign the new
package.
Supply basic VSPackage information. The wizard prompts you
for details such as the company name,
VSPackage name, version, icon,
detailed information, and minimum
Visual Studio edition (such as
Professional or Enterprise) that the
package is designed to at this step.
This information goes into the Visual
Studio splash screen and About dialog
box and is also used to request a PLK
for the package (covered later).
Select VSPackage options. A package may add three types of
functionality: Menu Command, Tool
Window, and Custom Editor.
A menu command is a command added either to the menu
at the top of Visual Studio or
to a context menu (right-click).
When the wizard finishes its job, the
VS SDK adds core elements to the
solution to support the new package.
For instance, if you selected Tool
Window as part of the functionality
for the package, the project contains
a user control where you should place
the visual controls for the window.
The project also contains files for
.NET code to handle the functionality
that you will add to the package.
A CtcComponents folder contains
pseudo-C++ files (ctc files) where you
define things like menu, groups,
buttons, etc. Fortunately, Microsoft
is phasing out CTC files and replacing
them with a friendlier, XML-based VSCT
file format (which will ship in the
SDK for Visual Studio 2008).
The wizard creates a few other files
with .NET code required for the
plumbing of the package within Visual
Studio. Some of these files contain
classes that map the C++ constants to
.NET constants and other files contain
configuration information for the
package when it’s installed.
I know it has been a long time, but it appears, at least in newer versions of Visual Studio for the VB (Basic) language, to be an setting in the options.
Text Editor > Basic > Advanced
Under "Go to Definition".
I don't know why they don't have that for other languages...
Place the mouse cursor on the object you want to access on the object browser. Then, use the keyboard shortcut ctrl + alt + j, which will take you directly to the Object Browser window.

Display multiple UserControls with the same name in the Visual Studio WinForms designer toolbox

In my WinForms project I have multiple UserControl-s with the same name ("View"), in diferent namespaces.
If I understand well, the designer hides the controls with the same name as the designed control from the toolbox. So when I'm in design mode on one of the "View"-s I don't see the other ones.
Is there a way to change the name displayed in the toolbox for an UserControl ? I have tried using DisplayNameAttribute or ToolBoxItemAttribute with no succes. Also DescriptionAttribute doesn't see to work either (I was expecting the description to be added to the toolbox item tooltip)
Or is there another way to display multiple UserControl-s with the same name in the Visual Studio WinForms designer toolbox ?
Using Visual Studio 2008
You can do this if you add each control to a different tab in the toolbox (just right-click in the toolbox and select Add Tab. Name each after the namespace.). This is how VS supports having controls with the same names between WinForms and web apps, for example.

Resources