Visual Studio 2010 Simple Form - visual-studio-2010

I've been searching, testing and trying a lot of things to create my project with Visual Studio 2010 Pro.
What I need is the same thing as Windows Form Application but ONLY in C++ (no managed stuff). So I guess I should be creating an MFC application. However, is there a way to design the main window? In the resources of the project, there are only the resources used by the main window, but it seems not possible to design (with the toolbox) the main window itself.
Am I missing something here? Anyone knows how to do this or point me to a good tutorial. I'm still searching for a solution, and I'll post it if I find it.
Thanks a lot!

You can either create a dialog-based app (as Hans wrote): The resource editor will let you add/move/size/configure controls to your dialog.
Or alternately, you can create a SDI MFC application and choose CFormView as the base class for the main view. This way, your main view (aka form) is a dialog that you can fill in using the resource editor the same way you would do with a dialog.

Related

Making tool window show automatically on VS load

In my Visual Studio extensibility project, I'm attempting to make my tool window visible upon launch after package installation.
The dotneteers describe a way of doing this that involves adding the following line to the package header (i.e. MyPackage.VSPackage.cs):
[ProvideToolWindowVisibility(typeof(MyToolWindow), Microsoft.VisualStudio.Shell.Interop.UIContextGuids80.NoSolution)]
Unfortunately, this doesn't work. It seems that Visual Studio doesn't pay attention to the "NoSolution" tool visibility directive (I can confirm that it does work for some of the other enumeration items, like Debugging, but this doesn't fit my use case).
If there's no way to make this auto-show the tool window on VS load, has anyone come up with any alternate (i.e. novel :)) solutions?
Alternatively, you can try making you package as auto load using ProvideAutoLoad and once at the Initialize() try to create this tool window. Use the Package.FindToolWindow() method.

Controls disappear in design mode using visual studio 2005

I'm working in a windows forms project using visual studio 2005 sp1, i've a lot of usercontrol that use for my user interface, yesterday i start to have problem with the designmode, when i open a usercontrol all control disappear, i check the design file and the definition of the controls is still there, when i run the app there is no problem.
I try to use this code inside the Load of every usercontrol
if (!this.DesignMode)
{
// Put some logic here
}
however, the problem persist. Today my usercontrol doesn´t display in designmode but either in runtime.
How can be posible? Any suggestion for that?
Regards,
Francisco.
I've had the same problem. Check the .Designer.cs file again and make sure the controls which disappeared are added to their parent controls. Like
this.pCheck.Controls.Add(this.pCheck_bLog_browse);
While checking the differences with previous revisions I figured out that for some reason these lines just disappeared.

Writing VS2010 Extension

I'd like to create an extension for Visual Studio 2010. The functionalities I need are these:
Add a context menu item for Project (when user right clicks project name in his solution, he'll get my context item in the list).
When he clicks, a new WinForms form appears, where he can input some data, and an option to save that data for future reuse.
When he clicks OK on that Form I'll generate some files and add those files to be a part of his project that he rightclicked.
The WSCF.blue is exactly the kind of behaviour I want to immitate in VS, but it's source was written in VS2008, and I'd like to use VS2010 Extension options which are quite changed as I understand...
I found some resources on the msdn, but I found it confusing with incomplete info (e.g. MenuAndCommands example).
Can anyone shed some light on how to achieve what I'm after?
I really don't know where to point out so you can get specific examples of what you are trying to achieve. However, in the following resources you will find complete and detailed information about the overall process, and some help to achieve 1. and 2.
VS 2010 Package Development – Chapter 1: Visual Studio Packages
VS 2010 Package Development – Chapter 2: Commands, Menus and Toolbars

Creating a Windows GUI .exe application

I have a C/C++ algorithm that I want to create a GUI application for. I would prefer a .exe application that I can pass around to people. I would preferably want to create a dll of my c/c++ algorithm and then bundle it into the Windows GUI application which is basically just a wrapper around the main c/c++ application. How can I create this GUI in VC++ all with a couple of buttons, a text box and a file chooser/browser/opener?
Can someone throw some light on this problem?
Thanks,
Abhishek
There's a number of different options. First we have the microsoft-supported libraries:
MFC - The most heavy-weight library for the windows api.
ATL - A somewhat smaller, lightweight library.
Windows API - Use the Windows API directly.
Beyond that there's a number of third party GUI toolkits, notably:
GTK+
WxWidgets
If you want to make it as small as compact as possible and avoid external DLLs, you should use the Windows API directly or possibly ATL. This also gives you additional flexibility, but it's a bit more complicated. Take a look at for example theForger's tutorial. It's a bit old, but the api has remained more or less the same for the last ten years anyway.
Here's some additional pointers for using the API directly:
What is usually known as controls is called "windows" and are created using CreateWindowEx(). This function creates different things depending on the specified "window class", such as edit, button and static (described below). You create a regular window by registering a custom class.
You can use a function called GetOpenFileName() to invoke an open dialog.
The common text box is known as the edit control in the API.
Buttons are simply called button controls.
Labels are called static controls.
If it's enough for your purposes, you can also create a dialog window using CreateDialog(). This is possibly a bit easier, since dialogs can be designed using the resource editor, while you have to create all the controls in a regular window programmatically.
In Visual Studio:
File -> New Project
In the left panel choose "Visual C++" (or C# if you prefer) and in the right panel choose Windows Forms Application. Click Ok.
When your project is created, in the Toolbox panel you can find Button, Edit Box, OpenFileDialogs and SaveFileDialogs (which you need). If you can't find Toolbox panel, you can enable it in View->Toolbox menu.
Place the controls you need on the program window as you wish by simply dragging them over.

Visual Studio ‘Go To Definition’ menu option behaviour - Why is it inconsistent between C# and VB projects

When developing in a VS2005+ with C# project and I right click on a framework method/property/type and select ‘Go To Definition’, by default we get a new locked tab with code that has been generated from the framework, labelled appropriately [from metadata].
However when we do the same in a VB.NET project, you get taken to a new tab with the relevant Object Browser view.
This has always struck me as peculiar and was hoping there was a good reason behind it. IMO the object browser is nicer.
Is there a logical reason for the difference in default visual studio behaviour? If so, what is it?
It's a choice each team made based on what they believe their respective customers wanted to see. VB users have a historical attachment to the object browser and many VB features are integrated into it (Go To Def being one of them). C# made a switch in VS2005 to generate metadata on the fly for their version of GoTo def because they believed their customers would like the behavior better.
You can install Resharper for this.
It'll allow you to choose the default behavior when clicking the "go to definition".

Resources