Fenster [SICHER] in den Vordergrund bringen!
-
Hi Leute,
und zwar hab ich mom. ein großes Problem, ein bestimmtes Fenster im Vordergrund zu halten.
Es gibt manchmal folgenden Fall:
Fenster ist im Hintergrund und wird nicht aktiviert, GetForegroundWindow() gibt aber das richtige Handle zurück.Mein aktueller Code:
//-------------------------------------- // Purpose: try activating frame for capturing //-------------------------------------- bool CCaptureFrame::DoFrameActivation( bool frame_select ) { if( IsWindow(m_BasehWnd) ) { if( IsIconic(m_BasehWnd) ) { // restore window ShowWindow( m_BasehWnd, SW_RESTORE ); }//if else { // simple show ShowWindow( m_BasehWnd, SW_SHOW ); } // bring window to front, use komplex activation DWORD lpProcessBasehWnd = GetWindowThreadProcessId( m_BasehWnd, 0 ); DWORD lpProcessCurrhWnd = GetWindowThreadProcessId( GetForegroundWindow(), 0 ); // --------------------------------------------------------------------- // // --------------------------------------------------------------------- if( lpProcessBasehWnd == lpProcessCurrhWnd ) { SetForegroundWindow( m_BasehWnd ); } else { // attach input to other process AttachThreadInput( lpProcessCurrhWnd, lpProcessBasehWnd, true ); SetForegroundWindow( m_BasehWnd ); AttachThreadInput( lpProcessCurrhWnd, lpProcessBasehWnd, false ); } }//if return true; }
-
Hi, sry war eine ältere Version:
if( IsWindow(m_BasehWnd) && GetForegroundWindow() != m_BasehWnd ) { if( IsIconic(m_BasehWnd) ) { // restore window ShowWindow( m_BasehWnd, SW_RESTORE ); }//if else { // simple show ShowWindow( m_BasehWnd, SW_SHOW ); } // bring window to front, use komplex activation DWORD lpProcessBasehWnd = GetWindowThreadProcessId( m_BasehWnd, 0 ); DWORD lpProcessCurrhWnd = GetWindowThreadProcessId( GetForegroundWindow(), 0 ); // --------------------------------------------------------------------- // // --------------------------------------------------------------------- if( lpProcessBasehWnd == lpProcessCurrhWnd ) { SetForegroundWindow( m_BasehWnd ); } else { // attach input to other process AttachThreadInput( lpProcessCurrhWnd, lpProcessBasehWnd, true ); SetForegroundWindow( m_BasehWnd ); AttachThreadInput( lpProcessCurrhWnd, lpProcessBasehWnd, false ); } if( frame_select ) { SelectFirstItem(); } }//if return true; }Ich muss noch dazu sagen, dass dieser Code jede Sekunde durchgeführt wird.
-
Ein kleines Feedback wäre ne super Sache
