Create a modeless Dialog as topmost window
Most of the time, in your applications, you may need a second dialog stand always open on demand to select something from it so your view will change relevantly. In order to that you can simply create a modeless dialog box, then make it the topmost window and then show or hide it in proper conditions. Event if you have minimized the mainframe, the modeless topmost dialog is still be visible, unless you handle it. Let is go on and see how can we do this. (an SDI application and a modeless topmost helper dialog box)
Vocabulary:
CMyDialog => Your dialog class ,
m_wndMyDialog => your member dialog class object ,
wndTopMost => Places the window above all nontopmost windows. The window maintains its topmost position even when it is deactivated. (you can also specify other parameters to SetWindowPos like window x,y leftmost upper point and height -width of the dialog etc. ) ,
bActive => if bActive is TRUE , then the application window is activated.
STEPS to implement
1) Declare a dialog class member object variable inside MainFrame class.
protected:
m_wndMyDialog CMyDialog;
2) In the CMainFrame::OnCreate() function override.
m_wndMyDialog.Create( IDD_MYDIALOG ); //creation
m_wndMyDialog.SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE, SWP_NOSIZE ); // style WS_EX_TOPMOST
3)
In the CMainFrame::OnActivateApp() function override.
if( bActive ) // if the application is activated
{
m_wndMyDialog.ShowWindow(SW_SHOW);
}
else // if the application is de-activated
{
m_wndMyDialog.ShowWindow(SW_HIDE);
}