关闭

改变窗口层叠的顺序

2997人阅读 评论(0) 收藏 举报

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.

系统安排优先级时,前台窗口的线程会略高于其他的线程。

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:49562次
    • 积分:693
    • 等级:
    • 排名:千里之外
    • 原创:14篇
    • 转载:9篇
    • 译文:2篇
    • 评论:8条
    文章分类
    最新评论