How to bring a window foreground using c#?

前端 未结 6 1441
遥遥无期
遥遥无期 2020-12-30 13:37

I am trying to bring a window foreground. I am using this code. But its not working. Could someone please help?

ShowWindowAsync(wnd.hWnd, SW_SHOW);

SetForeg         


        
6条回答
  •  自闭症患者
    2020-12-30 14:18

    As of Windows 7 these features dont behave quite so well. If there is an application such as Excel in front of the application you want to bring to the front then Windows 7 blocks this and flashes the window. You can set a registry timeout setting ForegroundLockTimeout=0 in HKEY_CURRENT_USER\Control Panel\Desktop but these is known as stealing focus. To set the behaviour of how XP "should" behave and will behave in Windows 7 by default you can create/set the value to 0x00030D40 (200000ms). I'd like to know what is the preferred solution for trusted Windows applications. eg. If I trust application B to take focus when I double click something in Application A, and some other app is obscuring the window of Application B.

提交回复
热议问题