How to create a topmost window using SetWindowPos?

A topmost window is one which stays on top of other windows even while it’s not in focus. Normally all application popup windows will go to background once they lose focus but a topmost window doesn’t. Let me explain or show you the code which does this. Everybody knows how to achieve this but still […]
Continue reading…

 

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…

 

How about tooltips for my controls on a dialog!

Recenty a colleague of mine came up and asked if it’s possible to display tooltips for toolbar buttons and other controls without much difficulty. So I gave him the solution and also decided to post it here for anyone who doesn’t know. When a tooltip text is to be displayed the framework sends a TTN_NEEDTEXT […]
Continue reading…

 

Changing the tab order of a control at runtime!

Follow these steps(Just a demo)… Add two buttons to a fresh dialog in a sequencial order, IDC_BUTTON1 and IDC_BUTTON2 Goto OnInitDialog(you are not restricted to OnInitDialog, you can also do this on a button click) and paste this line of code [sourcecode language=’cpp’]GetDlgItem( IDC_BUTTON1 )->SetWindowPos(GetDlgItem( IDC_BUTTON2 ), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | […]
Continue reading…

 

Moving child windows of a window at one go!

Here is a function that moves all child windows of a window at one go! 🙂 [sourcecode language=’cpp’]void MoveChildWindows( HWND hParentWindow, const POINT& ptOffset ) {    // Parent window should be valid    if( !hParentWindow || !::IsWindow( hParentWindow ))    {       ASSERT( FALSE );       return;    }    // Get first child […]
Continue reading…