CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    1

    SetForegroundWindow in Windows98/NT5



    I am trying to find a way around the new behaviour of

    SetForegroundWindow in Windows 98 and NT 5.


    Now it performs a FlashWindowEx call instead of allowing

    an application to force its window into the foreground.


    Anyone have a workaround?


    Undocumented flag?


    FYI: SystemParameterInfo( SPI_SETFOREGROUNDFLASHCOUNT, 0 )

    causes the window to flash forever.


    Thanks in advance,

    Adrian



  2. #2
    Join Date
    Dec 2000
    Posts
    1

    Re: SetForegroundWindow in Windows98/NT5



    Hi Adrian,


    use instead of SPI_SETFOREGROUNDFLASHCOUNT the flag SPI_SETFOREGROUNDLOCKTIMEOUT with zero as value.


    Ewald

  3. #3
    Join Date
    Jul 1998
    Posts
    1

    Re: SetForegroundWindow in Windows98/NT5



    Use AttachThreadInput to connect input state with the active thread. This will cause Windows 98 to perform SetForegroundWindow as in Win95. It also works in NT 5.0.


    Try this code (error check omitted):


    DWORD dwThreadId = GetCurrentThreadId();

    DWORD dwActiveThreadId = NULL;


    CWnd* pActiveWnd = GetForegroundWindow();


    dwActiveThreadId = GetWindowThreadProcessId( pActiveWnd->m_hWnd, NULL );


    AttachThreadInput( dwThreadId, dwActiveThreadId, TRUE );


    pPopup->SetForegroundWindow();


    AttachThreadInput( dwThreadId, dwActiveThreadId, FALSE );


    This workaround works in my code, but AttachThreadInput() has some side effects, you may want to consult documentation on it.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured