How to ignore Window activate ?
-
My application creates modeless dialog (in separate thread). The problem is that after creating of window system activates it and will put it foreground. How to create it without setting it active ? How to restrict this window so that could be activated only by user ? I tried to do this :
OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
{
if (nState == WA_ACTIVE)
if (pWndOther)
::SetActiveWindow(pWndOther->m_hWnd);
}But pWndOther is always NULL. Any ideas ? Thank you
rrrado
-
My application creates modeless dialog (in separate thread). The problem is that after creating of window system activates it and will put it foreground. How to create it without setting it active ? How to restrict this window so that could be activated only by user ? I tried to do this :
OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
{
if (nState == WA_ACTIVE)
if (pWndOther)
::SetActiveWindow(pWndOther->m_hWnd);
}But pWndOther is always NULL. Any ideas ? Thank you
rrrado
First create the Dialog that you want with the resource editor. BE CAREFULL YOU MUST REMOVE THE "Visible" style from ("More Styles") in the dialog properties. OR YOU WILL GET A CRASH.!! Then you must Create a new Class Inherited from CDialog. Lets say CUpdateDialog :: public CDialog with a resource template.. (the dialog editor); then Create a variable (Object) of the new class. Lest say CUpdateDlg m_UpdateDlg; then go .... m_UpdateDlg.Create (IDD_UPDATEDIALOG,this); // This will actuallly do the trick! m_UpdateDlg.ShowWindow (SW_SHOWNOACTIVATE);
-
My application creates modeless dialog (in separate thread). The problem is that after creating of window system activates it and will put it foreground. How to create it without setting it active ? How to restrict this window so that could be activated only by user ? I tried to do this :
OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
{
if (nState == WA_ACTIVE)
if (pWndOther)
::SetActiveWindow(pWndOther->m_hWnd);
}But pWndOther is always NULL. Any ideas ? Thank you
rrrado
Sorry about previews post... You must also disable the "Desabled" style from "More Styles" in the resource editor and use this m_UpdateDlg.ShowWindow (SW_SHOWNA); m_UpdateDlg.ModifyStyle (WS_DISABLED,NULL,0); instead of m_UpdateDlg.ShowWindow (SW_SHOWNOACTIVATE);
-
Sorry about previews post... You must also disable the "Desabled" style from "More Styles" in the resource editor and use this m_UpdateDlg.ShowWindow (SW_SHOWNA); m_UpdateDlg.ModifyStyle (WS_DISABLED,NULL,0); instead of m_UpdateDlg.ShowWindow (SW_SHOWNOACTIVATE);
Thank you very much ! :rose: I also have idea about DISABLED, but i didn't try it, i thought it won't work :) BTW your solution works so that it won't steal focus, but anyway will create window in z-order higher than parent window (althought it is created like child of desktop window). So I improved that to this :
m\_dlg.Create(IDD\_MANUAL,CWnd::FromHandle(GetDesktopWindow())); ::SetWindowPos(m\_dlg.m\_hWnd,AfxGetMainWnd()->m\_hWnd,0,0,0,0,SWP\_NOMOVE|SWP\_NOACTIVATE|SWP\_NOSIZE|SWP\_SHOWWINDOW); m\_dlg.ModifyStyle(WS\_DISABLED,0);
thank you again
rrrado