CD ROM present in CD Drive?

Good question! The easiest and working method is to call GetVolumeInformation on a CD-Drive, this function call will fail if no valid volume information is available for a drive this means CD-ROM drive should be valid one too! So our next job is to find out whether we have a CD-Drive in our machine, for […]
Continue reading…

 

Changing background color of dialogs and controls

Windows provides us with a message called WM_CTRLCOLORDLG which helps us in changing background color of a dialog. If we are handling this message then we need to return brush which is used for drawing background color. This means we can provide custom brushes. Don’t forget that we’ve got maintain such custom brushes since these are […]
Continue reading…

 

Visual studio shortcuts that I use

Some useful shortcuts for development in different versions of visual studio for VC++… Ctrl + Alt + L – Solution explorer Alt + Enter – Properties window Works even on open files in the IDE. Lists the properties of files like full path etc. If in resource editor then it shows properties of controls Ctrl […]
Continue reading…

 

Performance measurement functions in windows

Sometimes it does become mandatory to check performance or log performance of certain function calls, something like mini profiling. There are some functions in windows which helps us in doing this. I will rank them in their importance… QueryPerformanceCounter GetTickCount clock Of these three QueryPerformanceCounter is the best providing us with a high resolution counter. […]
Continue reading…

 

Quick way to hash data using WinAPI

Use HashData. // Usage: [sourcecode language=’cpp’]// A magical string to get hashed TCHAR szDataToHash[] = _T( “Oobolooblahblah, abracadabra, ooboboblablah, get this string hashed” ); // Determines the size of hash value to be returned. DWORD HashVal = 0; // Hash now HRESULT hRes = HashData( LPBYTE( szDataToHash ), // Data to hash, can be of […]
Continue reading…

 

Posting message to a thread

Use PostThreadMessage API to post message to threads in windows provided you have the thread id of a thread. Another thing to keep in mind to provide a message loop in your thread proc to watch for messages being posted, which means your thread will be blocked for message processing. E.g. I assume you have […]
Continue reading…

 

Move a window to foreground!

There are times when this feature is quite an annoyance! You are typing in a password and immediately this window pops up in front of you with the focus set on an edit control, so everybody sees your password as you are not aware that another window has come up. A good example would be […]
Continue reading…

 

Set/Get mouse double click time

To set double click time use SetDoubleClickTime Set time to zero to switch to default time of 500 milliseconds E.g. [sourcecode language=’cpp’]// If call succeeds return value is non zero VERIFY( SetDoubleClickTime( 200 )); // Set double click time to 200 milliseconds[/sourcecode] To get double click time use GetDoubleClickTime Returns double click time in milliseconds […]
Continue reading…

 

SystemParametersInfo

SystemParametersInfo is a powerful function which does and retrieves whole lot of things related to windows general behavior for eg: turning on and off certain features like mouse trails which we normally do via control panel->main.cpl Look up MSDN for more information on SystemParametersInfo. I’ll just show a demo on how to turn on and […]
Continue reading…