I have a desktop application. I want to invoke
a modeless dialog from my application. Thus, I created a dialog using ‘CXTPPropertySheet’class. These
are my requirements - Though my dialog is modeless I want it to be always in
front. From my dialog I invoke a separate dialog. Now the new dialog should be
the active one and in front. But if I again click on my dialog it should be the
active and it should be in front.
This is my code –
Class Declaration - class JFEAOptimizationMainDlg : public CXTPPropertySheet { DECLARE_DYNAMIC(JFEAOptimizationMainDlg)
private: }; Class Constructor -
JFEAOptimizationMainDlg::JFEAOptimizationMainDlg(JFEACreateOptimizationCmd*
pCmd, CWnd* pParentWnd)
{
HMODULE hDCXResource = NULL;
HINSTANCE hInstPrevious = NULL;
HWND hWnd = GetSafeHwnd();
JMGetPartDCXResourceModuleHandle(hDCXResource);
if( NULL != hDCXResource )
{
hInstPrevious = AfxGetResourceHandle();
AfxSetResourceHandle( hDCXResource
);
}
CXTPPropertyPageListNavigator* pList = new CXTPPropertyPageListNavigator(); pList->SetListStyle(xtpListBoxOffice2007);
SetNavigator(pList);
m_psh.dwFlags |= PSH_NOAPPLYNOW;
// Add pages on main dialog.
AddPage(&m_DesOptObjectivePage);
AddPage(&m_DesOptLimitsPage);
AddPage(&m_DesOptVariablesPage);
AddPage(&m_DesOptCtrlParamPage);
AddPage(&m_DesOptConvParamPage);
// Create the dialog and display it.
Create();
SetWindowPos( &this->wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); SetResizable();
}
With
this code in place, my dialog always remains on top of all windows present. E.g.
If I open IE then also my dialog appears in front. If I invoke a new dialog from
my dialog then the new dialog goes behind my dialog. If I click on new dialog it
does not come on front. This is annoying. In the ‘SetWindowPos’
function I
tried setting the firs parameter to ‘this->wndTop’ but then my dialog does not remain in front; and it
minimizes if I click somewhere else in my application. Please refer this image. I
also tried sending different parameters to ‘Create’ function but none helped.
I found that for modeless dialogs the create method should be called like this –
Create(JFEAOptimizationMainDlg::IDD, NULL);
However
since ‘CXTPPropertySheet’ does not have a resource associated with (no template id for my dialog)
it I can’t use this.
Please
help me to figure out the problem here. How can I achieve my required behavior?
Let me know whether this is a limitation of codejock.
I
have a urgency for this fix.
------------- Thanks & Regards, Satyenjit Bagal. Software Development Engineer. SIEMENS Automation and Drives.
|