改變窗口層疊的順序

BringWindowToTop

The BringWindowToTop function brings the specified window to the top of the Z
order. If the window is a top-level window, it is activated. If the window is a
child window, the top-level parent window associated with the child window is
activated.
函數bringWindowToTop 把指定窗口置於"Z order"的頂層。如果窗口是最高級窗口,那麼他
將被激活。如果窗口是子窗口,那麼和這個子窗口連接的最高級父窗口將被激活。

BOOL BringWindowToTop(
    HWND hWnd  // handle to window );

Parameters

hWnd

Identifies the window to bring to the top of the Z order.

 

Return Values

If the function succeeds, the return value is nonzero. If the function fails,
the return value is zero. To get extended error information, call GetLastError.
如果成功,返回非零值。如果失敗,返回0。獲得進一步的錯誤信息,使用
GetLastError函數。

Remarks

Use the BringWindowToTop function to uncover any window that is partially or
completely obscured by other windows. Calling this function is similar to
calling the SetWindowPos function to change a window's position in the Z order.
BringWindowToTop does not make a window a top-level window. If an application is
not in the foreground and wants to be in the foreground, it should call the
SetForegroundWindow function.

提示:如果使用BringWindowToTop函數去覆蓋那些被其他窗口部分或者全部佔用的部分。
調用這個函數比調用函數SetWindowsPos改變一個窗口的位置到Z order 要簡單。
BringWindowToTop不能使一個窗口成爲頂級窗口。如果一個程序不是在前臺,並且想
在前臺,可以使用SetForegroundWindow函數。

 

SetForegroundWindow

The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user.
把用這個線程生成的指定窗口放到前臺,並且激活這個窗口。鍵盤輸入直接輸入到這個窗口,
並且various visual cues are changed for the user.^_^

BOOL SetForegroundWindow(

    HWND hWnd  // handle of window to bring to foreground
   ); 
 

Parameters

hWnd

Identifies the window that should be activated and brought to the foreground.

 

Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The foreground window is the window at the top of the Z order. It is the window that the user is working with. In a preemptive multitasking environment, you should generally let the user control which window is the foreground window. However, an application can call SetForegroundWindow if it wants to put itself into the foreground to display a critical error or information that requires the user's immediate attention. A good example is a debugger when it hits a breakpoint.
前臺窗口是z order的頂級窗口。他是用戶用於工作的窗口。在多任務的環境中,你只能然用戶控制前臺的窗口。但是,程序可以調用SetForegroudWindow如果他想把自己放到前臺,顯示嚴重的錯誤或者需要用戶注意的信息。程序調試器在遇到斷點的時候,就是這樣的一個好例子。


The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.

系統安排優先級時,前臺窗口的線程會略高於其他的線程。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章