SystemApi.SetWindowPos(MainHwnd_, -1, 0, 0, 0, 0, 1 | 4);
SystemApi.SetWindowPos(MainHwnd_, -1, 0, 0, 0, 0, 1 | 2); [DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);试试这个。
谢了,问个问题,被SetForegroundWindow的窗体,线程会被其他弹出的窗体打断吗
什么叫打断?你是想让其最前端显示吧?一般的做法是先改变Z-Order让其最前端显示,然后再置顶,最后还原Z-Order
hForeWnd = GetForegroundWindow();
dwCurID = GetCurrentThreadId();
dwForeID = GetWindowThreadProcessId( hForeWnd, NULL );
AttachThreadInput( dwCurID, dwForeID, TRUE);
ShowWindow( hWnd, SW_SHOWNORMAL );
SetWindowPos( hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE ); //设置最前端显示
//SetWindowPos( hWnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE );
SetForegroundWindow( hWnd ); //激活窗口
AttachThreadInput( dwCurID, dwForeID, FALSE);红色代码是调用成功的前提
谢了,问个问题,被SetForegroundWindow的窗体,线程会被其他弹出的窗体打断吗如果他也是顶层显示的话你需要做个时钟去一直置顶它。
是这样的,写的一个东西操作Q~,但是过程中如果有其他软件弹出的窗体的话,线程就会断掉。
想加个SetForegroundWindow,防止线程中断