导航
  • 主页
  • VC综合技术
  • 互联网技术
  • MFC AppLauncher
  • .NET 技术
  • 界面
  • 进程
  • 算法
  • 硬件/系统
  • 数据库
  • VC++技术资源

200分!高手!做一个置于顶层的窗口??

sunyuzhe 2002-07-27 09:06:31
做一个置于顶层的窗口,但是点击它时却是要它下面的窗口响应鼠标的消息。
...全文
186 点赞 收藏 30
写回复
30 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
TOPMOST
回复
sh210 2002-09-08
mark
回复
fireseed 2002-09-08
找到本窗体下面的一个窗体:


GetWindow(hThisWnd, GW_HWNDPREV);


然后用GetWindowRect和GetCursorPos判断数标是否在此窗体内,如果不在,再用上面的函数找下一个窗体直到找到为止
回复
Hankuu 2002-09-08
1.先用该函数使下面窗口获得鼠标焦点
HWND SetCapture(
HWND hWnd // handle to window
);

2.在用mouse_event模拟鼠标点击
VOID mouse_event(
DWORD dwFlags, // motion and click options
DWORD dx, // horizontal position or change
DWORD dy, // vertical position or change
DWORD dwData, // wheel movement
ULONG_PTR dwExtraInfo // application-defined information
);

3.还原鼠标焦点到你的顶层窗口
回复
cdz0001 2002-09-08
setwindowspos()做一个置于顶层的窗口,很简单
================================================================

CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!

★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。

★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。

Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]

回复
bxb1280 2002-09-08
SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
回复
llwwwww 2002-09-08
同意楼上的
回复
yyszh 2002-09-08
创建顶层窗口不难,关键是要找到它下面的那个窗口,用FindWindow肯定不行,似乎用Z-Order可以试试,然后SendMessage。
回复
In355Hz 2002-09-08
可以创建一个WS_DISABLED属性的窗口,然后调用WindowFormPoint取得鼠标位置窗口句柄,然后调用PostMessage发送鼠标消息。
WS_DISABLED属性是必须的,不然,还要处理键盘焦点。
回复
everandforever 2002-09-08
我记得窗口有个TRANSPARENT属性
回复
guzizhao 2002-09-08
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
::SetWindowPos(GetSafeHwnd(),HWND_TOPMOST,0,0,wp.rcNormalPosition.right,
wp.rcNormalPosition.bottom,SWP_SHOWWINDOW);
回复
babytiger 2002-09-08
CRect rect;
int cx,cy;
cx=GetSystemMetrics(SM_CXSCREEN)/2;
cy=GetSystemMetrics(SM_CYSCREEN)/2;
rect.SetRect(cx+2,cy+2,cx-2,cy-2);
CPen pen(PS_SOLID,1,cscol);
CWnd *pw;
pw=GetDesktopWindow();
pw->InvalidateRect(rect,true);
CWindowDC dc(pw);
dc.SelectObject(&pen);
dc.MoveTo(cx-15,cy);
dc.LineTo(cx+15,cy);
dc.MoveTo(cx,cy-15);
dc.LineTo(cx,cy+15);
dc.Ellipse(rect);
再定时刷新一下,就行了
回复
nicolas 2002-07-28
看我的一段代码:
//m_hWnd是欲置于最顶层的窗口的句柄
CRect RECT_Win;
::GetWindowRect(m_hWnd,&RECT_Win);
::SetWindowPos(m_hWnd,HWND_TOPMOST,RECT_Win.left,RECT_Win.top,
RECT_Win.Width(),RECT_Win.Height(),NULL);
回复
eggaig 2002-07-28
CWnd::SetWindowPos
BOOL SetWindowPos( const CWnd* pWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags );

Return Value

Nonzero if the function is successful; otherwise 0.

Parameters

pWndInsertAfter

Identifies the CWnd object that will precede this CWnd object in the Z-order. This parameter can be a pointer to a CWnd or a Pointer to one of the following values:

wndBottom Places the window at the bottom of the Z-order. If this CWnd is a topmost window, the window loses its topmost status; the system places the window at the bottom of all other windows.


wndTop Places the window at the top of the Z-order.


wndTopMost Places the window above all nontopmost windows. The window maintains its topmost position even when it is deactivated.


wndNoTopMost Repositions the window to the top of all nontopmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a nontopmost window.
See the “Remarks” section for this function for rules about how this parameter is used.

x

Specifies the new position of the left side of the window.

y

Specifies the new position of the top of the window.

cx

Specifies the new width of the window.

cy

Specifies the new height of the window.

nFlags

Specifies sizing and positioning options. This parameter can be a combination of the following:

SWP_DRAWFRAME Draws a frame (defined when the window was created) around the window.


SWP_FRAMECHANGED Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.


SWP_HIDEWINDOW Hides the window.


SWP_NOACTIVATE Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or the nontopmost group (depending on the setting of the pWndInsertAfter parameter).


SWP_NOCOPYBITS Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.


SWP_NOMOVE Retains current position (ignores the x and y parameters).


SWP_NOOWNERZORDER Does not change the owner window’s position in the Z-order.


SWP_NOREDRAW Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title and scroll bars), and any part of the parent window uncovered as a result of the moved window. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that must be redrawn.


SWP_NOREPOSITION Same as SWP_NOOWNERZORDER.


SWP_NOSENDCHANGING Prevents the window from receiving the WM_WINDOWPOSCHANGING message.


SWP_NOSIZE Retains current size (ignores the cx and cy parameters).


SWP_NOZORDER Retains current ordering (ignores pWndInsertAfter).


SWP_SHOWWINDOW Displays the window.
Remarks

Call this member function to change the size, position, and Z-order of child, pop-up, and top-level windows.

Windows are ordered on the screen according to their Z-order; the window at the top of the Z-order appears on top of all other windows in the order.

All coordinates for child windows are client coordinates (relative to the upper-left corner of the parent window’s client area).

A window can be moved to the top of the Z-order either by setting the pWndInsertAfter parameter to &wndTopMost and ensuring that the SWP_NOZORDER flag is not set or by setting a window’s Z-order so that it is above any existing topmost windows. When a nontopmost window is made topmost, its owned windows are also made topmost. Its owners are not changed.

A topmost window is no longer topmost if it is repositioned to the bottom (&wndBottom) of the Z-order or after any nontopmost window. When a topmost window is made nontopmost, all of its owners and its owned windows are also made nontopmost windows.

If neither SWP_NOACTIVATE nor SWP_NOZORDER is specified (that is, when the application requests that a window be simultaneously activated and placed in the specified Z-order), the value specified in pWndInsertAfter is used only in the following circumstances:

Neither &wndTopMost nor &wndNoTopMost is specified in the pWndInsertAfter parameter.


This window is not the active window.
An application cannot activate an inactive window without also bringing it to the top of the Z-order. Applications can change the Z-order of an activated window without restrictions.

A nontopmost window may own a topmost window, but not vice versa. Any window (for example, a dialog box) owned by a topmost window is itself made a topmost window to ensure that all owned windows stay above their owner.

With Windows versions 3.1 and later, windows can be moved to the top of the Z-order and locked there by setting their WS_EX_TOPMOST styles. Such a topmost window maintains its topmost position even when deactivated. For example, selecting the WinHelp Always On Top command makes the Help window topmost, and it then remains visible when you return to your application.

To create a topmost window, call SetWindowPos with the pWndInsertAfter parameter equal to &wndTopMost, or set the WS_EX_TOPMOST style when you create the window.

If the Z-order contains any windows with the WS_EX_TOPMOST style, a window moved with the &wndTopMost value is placed at the top of all nontopmost windows, but below any topmost windows. When an application activates an inactive window without the WS_EX_TOPMOST bit, the window is moved above all nontopmost windows but below any topmost windows.

If SetWindowPos is called when the pWndInsertAfter parameter is &wndBottom and CWnd is a topmost window, the window loses its topmost status (WS_EX_TOPMOST is cleared), and the system places the window at the bottom of the Z-order.



回复
sunyuzhe 2002-07-28
关键问题是你怎么知道它下面是哪一个窗口呀!
回复
lwglucky 2002-07-28
真难。。
回复
bljbljbljblj 2002-07-28
1。顶层显示就不用说了吧
2。列出Z-ORDER中的所有窗体
3。在Z—ORDER方向上从上往下依次判断点是否在窗体内,如果是,向该窗体发送消息

回复
zijingzelan168 2002-07-28
1 用setwindowpos函数设为顶层
2 在该顶层窗口捕捉消息,用API函数 SendMessage把该消息发给你下面的 窗口去处理
回复
dycdyc123 2002-07-28
SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE);

回复
czn 2002-07-28
很简单!
首先用setwindowpos函数设为顶层或者在创建窗口时设定
然后在该顶层窗口捕捉消息,用API函数 SendMessage把该消息发给你下面的窗口去处理!oK?
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……