我想编写一个应用程序,可以在屏幕上画一个矩形框,要求矩形框围于其他所有的窗口之上,并且不受其他程序的影响。也就是说:无论你在打开多少其他的窗口(甚至是看电影,玩游戏),所画的矩形始终浮在其上,并且不消失,除非关闭程序。有点类似于网上的一个叫《圣诞节礼物》的桌面程序一样。我使用了MFC中的GetDestopWindow,并且在OnDraw()函数中实现具体的操作。可是效果不行,当整个的屏幕刷新的时候,所画的矩形窗口就不见了,除非激活我的程序的窗口(其实我的程序不需要自己的窗口,只需一个最小化的图标控制程序的结束就可以了。但我是用MFC导向生成的基本框架,我又不会消除窗口的办法)。求各位大虾该如何实现这个功能。
BOOL SetWindowPos( HWND hWnd,
HWND hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
UINT uFlags
);hWndInsertAfter
[in] Handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values.
HWND_BOTTOM
Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
HWND_NOTOPMOST
Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
HWND_TOP
Places the window at the top of the Z order.
HWND_TOPMOST
Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
For more information about how this parameter is used, see the following Res section.
还是会被覆盖
用mfc的方法不怎么好解决这个问题!
因为mfc是基于窗口的句柄而来实现的,这个跟windows编程有关系,所以,应该查查windows编程!