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

sunyuzhe 2002-07-27 09:06:31
做一个置于顶层的窗口,但是点击它时却是要它下面的窗口响应鼠标的消息。
...全文
255 30 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
用户 昵称 2002-09-08
  • 打赏
  • 举报
回复
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?
加载更多回复(10)
一、整体功能描述: 本软件的设计初衷,就是最大限度的方便使用者来编辑、处理、产生各种格式的数据,让使用者不必为了处理文本数据,而来回动用多款软件,给软件爱好者在文本编辑上带来快捷、舒适的体验。不管如何,软件在设计中总有不足之处,对不同的使用者来说,总有很多考虑不周的地方,同时本软件也在不断改进与升级中,也希望高手们提出宝贵意见、以及希望本软件可以让大家用的开心。 本软件为绿色免费软件,目前内置功能如下: 1、 行列转换:将两段文本按自定义方式交错插入,以指定方式插入行、删除行等; 2、 C语言、汇编语言源码格式化:尤其对经常从网上收集代码、对格式排列有比较高的编程者适用,只需要单击一次按键,即可将杂乱的代码排列整齐,同时自动修正中文代替英文符号所产生的错误,可省去大量工作,本软件可直接对文件夹下的多个源文件进行操作; 3、 数据序列生成:自定义数字序列、随机数序列, 支持16进制、10进制,自定义生成的数字序列的前缀字符、后缀字符,隔方式等; 4、 多音色电子琴:支持用键盘演奏,并可对所演奏的内容进行回放以及自动对演奏的内容配节奏,并且很容易再次编辑(支持单行播放、从光标处播放、播放选定的内容、全部播放等调试方式),可以无失真的保存用户演奏的旋律,也可以“使用常规乐曲音符编码”自动将旋律对齐到常用的旋律上,用户还可以对照音乐书本直接录入音符与节奏,让本软件播放,播放时,可随意切换播放速度,本软件自带有《梁祝》、《天空之城》、《知不知道》、《大长今-希望》、《祝你一路顺风》、《遇上你是我的缘》等比较耐听的曲子让大家参考、试听,相信对学习电子琴与电子琴写歌曲有比较好的帮助; 5、 查找与替换:除了文本编辑器所必须的查找、替换,在文件夹中查找、替换外,本软件还集成了“快速替换”、以及“?方式替换”,当用记事本替换速度无法满足要求时,可以试一下比记事本快N倍的“快速替换”,当查找字符串中的某些字符不是固定时,则可用本软件的“?替换方式”,这种方式下,可用“?”代替任意一个字符来进行查找,如将 “t??est”替换成“test”; 6、 格式转换:如简繁的互转,GB转换成16进制的互转,GB与UCS2的互转,中英文符号的互转,大小写互转,16进制C与汇编格式互转,16进制与10进制格式互转等; 7、 人性化编辑:本软件拥有很多快捷菜单、操作,经常可以使操作一步到位,如一键去除空白字符等其它多种实用功能并兼容主流编辑器的操作,如按下Tab键由选定的内容增大缩进、Shift + Tab则选定的内容减小缩进,按下F3键则查找选定的内定等,也可直接将查找的内容使用“百度搜索”。在输出窗口中,可直接显示选定内容的各种编码转换结果,字数、字节数统计等; 8、 文件夹数据获取:获取整个文件夹中的文件列表,获取整个文件夹中的文件夹列表,获取前面两者; 9、 16进制编辑:简单实用,看了就会的16进制编辑工具; 10、串口调试助手:专门为自己写的一款串口调试助手,拥有自己想要的全部人性化功能,支持虚拟串口等,任意插拔USB转换的串口不会卡住; 11、行比较软件:比较两段文字是否匹配; 12、数码管字形编码工具:搞单片机的朋友们就知道啦; 13、JS/HTML格式化工具:对弄网页的朋友们比较实用; 14、置顶编辑器:这款编辑器总是置于顶层,方便经常需要从记事本、word等软件往其他应用程序(比如数据库)复制内容的朋友们; 15、日期计算:计算N天后、N天前的日期,日期与星期之间的转换; 16、文件夹自动命名备份:在文件接收模式时,将需要备份的文件夹拖到文件接收窗口中,即可将文件夹备份为:原文件夹名称+yyyy-mmdd-nnss,如将tqdPS 备份为 tqdPS-2011-0407-2205

16,547

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

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

试试用AI创作助手写篇文章吧