Window activation
-
Hi, I have a program, which has a timer and dialog. Program purpose is to set the window on top most and active in a specified interval. Problem is that the dialog is getting on the top most. That is ok. But not getting activated ( No focus ). Please see the code: void CTestSetWPosDlg::OnTimer( UINT nIDEvent ) { CDialog::OnTimer( nIDEvent ); SYSTEMTIME stSystemTime; GetLocalTime( &stSystemTime ); CString csTime; csTime.Format( "%d:%d", stSystemTime.wMinute, stSystemTime.wSecond ); SetWindowText( csTime.operator LPCTSTR()); SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS ); SetActiveWindow(); } Krishnakumar
-
Hi, I have a program, which has a timer and dialog. Program purpose is to set the window on top most and active in a specified interval. Problem is that the dialog is getting on the top most. That is ok. But not getting activated ( No focus ). Please see the code: void CTestSetWPosDlg::OnTimer( UINT nIDEvent ) { CDialog::OnTimer( nIDEvent ); SYSTEMTIME stSystemTime; GetLocalTime( &stSystemTime ); CString csTime; csTime.Format( "%d:%d", stSystemTime.wMinute, stSystemTime.wSecond ); SetWindowText( csTime.operator LPCTSTR()); SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS ); SetActiveWindow(); } Krishnakumar
you should get the return value of SetActiveWindow.if the return value is null,it means failure.then you can call GetLastError and get the error code.you can use the error lookup tool to get the reason for the failure.
-
you should get the return value of SetActiveWindow.if the return value is null,it means failure.then you can call GetLastError and get the error code.you can use the error lookup tool to get the reason for the failure.
-
are you sure?that means your window is active.
-
maybe you can use SetFocus.
-
maybe you can use SetFocus.
-
try to use the SetForegroundWindow.
-
try to use the SetForegroundWindow.
-
KKumarTG wrote:
Icon in the task bar is flashing...
BringWindowToTop
:~
Nibu thomas A Developer Programming tips[^] My site[^]
-
Hi, I have a program, which has a timer and dialog. Program purpose is to set the window on top most and active in a specified interval. Problem is that the dialog is getting on the top most. That is ok. But not getting activated ( No focus ). Please see the code: void CTestSetWPosDlg::OnTimer( UINT nIDEvent ) { CDialog::OnTimer( nIDEvent ); SYSTEMTIME stSystemTime; GetLocalTime( &stSystemTime ); CString csTime; csTime.Format( "%d:%d", stSystemTime.wMinute, stSystemTime.wSecond ); SetWindowText( csTime.operator LPCTSTR()); SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS ); SetActiveWindow(); } Krishnakumar
SetForegroundWindow() is working fine in my sample application. SetActiveWindow() only activates the window if the calling thread is foreground thread. Please see the KB http://support.microsoft.com/default.aspx?kbid=97925