Editing Visual Studio Menus

I use Visual Assist X every time that I develop because it is one of the most amazing and useful plugins for Visual Studio, ever. However for some reason the context menu shortcut disappeared for some reason and it greatly slowed down my productivity. For a while I searched and tried to find a solution, and I finally did. Here is how to edit menus in Visual Studio:

If you click on main menu Tools -> Customize… The Customize window will open. Click on the Toolbars
tab at the top and select Context Menu by placing a check mark in its box on the left. This will place a ToolBar at the top of The IDE. Select Project and Solution Context Menus drop down list. Select the context menu to edit and then right click on the menu item to remove and select Delete. To Add menu items go to the Commands table of the Customize window Select a Categories and from the Commands section Drag and Drop the command in the same area you just deleted the previous. You will need to play around with it.

Tags: , ,

TestDriven.net

I found out about this cool addin for visual studio, TestDriven.Net. If you do unit testing in Visual Studio, check this out (I believe that it works for both .NET langauges and C++).

Link

Tags: , , , ,

Creating DLLs with Visual Studio

DLLs are an important part of the Windows Operating system that will allow a program to dynamically load and execute code. This means that you could build an executable one day, and still make updates without re-releasing it.

Creating a DLL isn’t really all that difficult, and it only takes a few steps. This guide is particular to C++ and Visual Studio, so I don’t know whether or not you could use the same process for other compilers.

The first step is to create the code that you want to use. You could create the class or the functions, it doesn’t really matter. Take a look at the following example:

class testClass
{
public:
void testingFunction();
};

Now, this is your standard C++ basic class (without any definitions for the class, this will not link properly if you attempt to use it). All that needs to be done to make this class ready to use with a DLL is to add the Microsoft code for exporting a function/clas with __declspec(dllexport). So this is what the result is…

#define DLL_EXPORT __declspec(dllexport)

class DLL_EXPORT testClass
{
public:
void testingFunction();
};

Now the only difference is that there is a macro that places the dll export call into the class. Now the great part about this method is that should you ever need to maintain a static library and a dynamic library, you’ll be able to not modify any code (except for the DLL_EXPORT macro).

All the code is now present and everything should work. When you build the DLL it should also automatically build a import library (a lib).

__declspec(dllexport)

Tags: , ,

Automatic Build Incrementation

Automatic build incrementation is a great tool for keeping track of your current status versus the last binary that was built. It really helps to keep track of your binaries as you develop.

Options
You can do any ol’ Google search to find an automatic build incrementation tools. I found one once upon a time and it wasn’t quite what I wanted… so I built my own. KISS – keep it simple stupid, and the tools that I found were not that. Because Visual Studio allows you to run your own custom commands at different build stages, all you really need is some sort of application to increment a file.

Build Events

VS Build Event Example

VS Build Event Example

In any C++ Visual Studio project settings page you will find “Build Events” and there are three options, “Pre-Build Event”, “Pre-Link Event”, “Post-Build Event”. You can use whichever you want, but I tend to use Pre-Build or Post-Build event. Using my own special exe I put in “BuildVersion VersionNo.h” into the “Command Line” in the Pre-Build event. So everytime I build, the build number gets incremented (the last portion of the version number). With the command line tool I use, you can also increment the revision, minor, or major version number.

Demo Application

I have included a demo application, and my custom BuildVersion application. The demo application will allow you to understand how I integrated the BuildVersion into my Visual Studio projects.

Download source 16KB
Download binary 11KB

Tags: , , , , , ,

Replacing Winforms

If you have Visual Studio, there is a pretty good chance that you have played with the integrated visual designer. Using the visual designer in Visual Studio requires that you develop a .NET application. If you ever want to make your application crossplatform using winforms is not the best idea (although you could use the Mono platform as a crossplatform replacement for .NET). Because I wanted to have the ease of creating good UI visually without build a .NET application, I went out in search of a new GUI toolkit.

There are a few toolkits out there for building UI applications that are replacement for winforms. The three that I found to be the most popular are wxWidgets, Qt, and GTK.

wxWidgets

Excerpt from their website:
wxWidgets lets developers create applications for Win32, Mac OS X, GTK+, X11, Motif, WinCE, and more using one codebase. It can be used from languages such as C++, Python, Perl, and C#/.NET. Unlike other cross-platform toolkits, wxWidgets applications look and feel native. This is because wxWidgets uses the platform’s own native controls rather than emulating them. It’s also extensive, free, open-source, and mature.

Code::Blocks allows the integration of wxWidgets. Code::Blocks itself is a crossplatform IDE so its not a bad idea to use it in conjunction with wxWidgets if you are really looking for doing crossplatform applications. While I never really gave a really deep look into wxWidgets beyond the form designer, I didn’t find it to meet my needs. The way that you construct forms in wxWidgets was very different from the way that winforms seemed to work. With winforms you can drag and drop, but you cannot seem to do the same in wxWidgets as they work with resizers and regions instead of the easy drag and drop. I have no doubt that you can create some powerful applications, but the barrier to entry with wxWidgets was too large for me.

GTK

GTK is one of the most popular toolkits available for Linux (the other is Qt). The form builder application doesn’t seem to be too difficult. There is also binary distribution available for Windows (32 and 64 bit), Linux, and Mac OS X. Therefore you can create crossplatform applications without a lot of trouble. However, the problem with GTK is that it seems that it takes more code to do the same thing in GTK than you could in Qt, which moves me onto…

Qt

I ended up with Qt because it had almost everything that I wanted. The best thing was that the form designer was great and easy to use. Qt also has Visual Studio integration so that you can do everything from Visual Studio. Recently Qt has become under a tripe license, GPL, LGPL, and a pure commercial license. Concerns regarding the license have been a problem in the past because they only had a GPL and a Commercial license. Qt has a unique way of doing callbacks using a signal and slot method, which was one of the only things that I needed to look up and couldn’t get working without research. With the form builder there was a problem with a seemingly limited amount of widgets available compared to winforms. But for its few small problems Qt is a great piece of software for creating UI applications.

Tags: , ,