带有鼠标光标的消息框已锁定在其中。 [英] Message Box with Mouse Cursor locked in it.

查看:87
本文介绍了带有鼠标光标的消息框已锁定在其中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

有没有办法创建一个消息框,这样我们就可以将鼠标指针锁定在此框上,直到用户回答{Ok / Cancel}为止收到?

Is there a way to create a message box, such that we can lock the mouse pointer on this box till user’s answer { Ok / Cancel } is not received ??

我的项目(C / C ++,Windows 10)中运行了多个窗口。

My project (C/C++, Windows 10 )is such that there are multiple windows running in it.

如果出现错误遇到,会弹出一个消息框。但有时,在用户对消息框执行操作之前,会出现另一个窗口并将鼠标指针锁定在自身内{这不是顶部窗口}。

If an Error is encountered, a message box is popped. But at times, before the user takes an action on the message box, another window comes up and locks the mouse pointer within itself { this is not the top window }.

因此用户被卡住了。消息框不会让它继续,鼠标被另一个窗口锁定。

So user is stuck. Message box won’t let it proceed and mouse is locked by another window.

我想知道是否有办法强制将鼠标指针锁定到消息框。

I want to know if there is a way to force lock the mouse pointer to the message box.

因此没有其他窗口可以控制它。

So that no other window can take control of it.

请注意我使用的设备只有鼠标而没有键盘。所以ALT + TAB不是我的选择。

Please note that the device I am using has only mouse and no keyboard. So ALT+TAB is not an option with me.

我使用的是Windows 10操作系统和C / C ++

I am using Windows 10 OS, and C/C++

推荐答案

您好,

感谢您在此处发帖。

>>有没有办法创建一个消息框,这样我们可以将鼠标指针锁定在此框上,直到用户的回答没有收到{Ok / Cancel}?

对于这种情况,您可以尝试以下方式。

For this case, you could try these ways below.

1。致电  SetCapture
用于将鼠标捕获设置为属于当前线程的指定窗口的功能。当鼠标悬停在捕获窗口上时,或者当鼠标在捕获
窗口时按下鼠标按钮且按钮仍然按下时,SetCapture会捕获鼠标输入。 

1. Call SetCapture function to set the mouse capture to the specified window belonging to the current thread. SetCapture captures mouse input either when the mouse is over the capturing window, or when the mouse button was pressed while the mouse was over the capturing window and the button is still down. 

2。致电  ClipCursor
功能定义 光标到屏幕上的矩形区域。如果后续光标位置(由SetCursorPos函数或鼠标设置)位于矩形之外,系统会自动调整位置以将光标保持在
矩形区域内。

2. Call ClipCursor function to define the cursor to a rectangular area on the screen. If a subsequent cursor position (set by the SetCursorPos function or the mouse) lies outside the rectangle, the system automatically adjusts the position to keep the cursor inside the rectangular area.

希望这可以帮到你。

最好的问候,

Baron Bi


这篇关于带有鼠标光标的消息框已锁定在其中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆