Changing console application window icon at runtime!

Bored with the old black icon that you have on the main window. Here is a way to change it. There is an undocumented API called SetConsoleIcon and it’s in Kernel32.dll.  Here is how we use it… [sourcecode language=’cpp’]void ChangeIcon( const HICON hNewIcon ) {  // Load kernel 32 library  HMODULE hMod = LoadLibrary( _T( […]
Continue reading…

 

Use cout to print out bool values as true and false?

Have you tried printing out bool using cout. Well who hasn’t, and most of you might have got results like 0/1. For eg: [sourcecode language=’cpp’]cout < < "1 > 2: ” < 2 );[/sourcecode] Output 1 > 2: 0 Well how to print out true or false directly instead of 0 and 1. Use boolalpha […]
Continue reading…

 

Easy way to display Gif’s, Ico’s, JPEG’s and BMP’s on your window

Here is a function that does this! You only have to call this function with an image file, (gif, jpeg, jpg, bmp, ico) and a window handle onto which picture is to be painted. This is originally from MSDN but I modified it slightly to make it into one function… 😉 [sourcecode language=’cpp’]// This function loads […]
Continue reading…

 

How to convert between short and long path names

Use GetShortPathName to get short file name for a given long file name. Use GetLongPathName to get long file name for a given short file name. Eg: [sourcecode language=’cpp’]TCHAR szPath[MAX_PATH] = { 0 }; GetShortPathName( _T( “C:/Program Files/Microsoft Visual Studio” ), szPath, MAX_PATH ); MessageBox( NULL, szPath, _T( “Short path” ), MB_OK ); TCHAR szShortPath[MAX_PATH]; […]
Continue reading…

 

Build times in Visual Studio 6

Add /Y3 to msdev as command line, but you may say that this is not possible always when I click on visual studio icon. Add a shortcut to msdev and in the “Target” edit box, to the end, add this option as /Y3. Now whenever you startup visual studio using this shortcut you should get build […]
Continue reading…