应用程序窗口中的光标类型不正确

发布于 2024-10-08 23:33:37 字数 368 浏览 2 评论 0原文

在尝试使用 Windows API 制作 GUI 之后,我最近意识到了光标的问题。当我编译并运行我的应用程序时,它会显示一个像预期的窗口。当我将光标从屏幕左侧拖动到应用程序窗口时,当它越过边框时,它会变成 <->调整大小的东西,但它仍然像我窗口内的任何地方一样。如果我把它从底部带入窗口,情况也是如此。但当我从右侧这样做时,问题就不存在。我怀疑这是否只是我的程序,所以我去了 MSDN 网站,甚至编译并尝试了他们的程序(http://msdn.microsoft.com/en-us/library/ff381409%28v=VS.85%29.aspx )。同样的问题!于是我开始尝试 WM_SETCURSOR 消息和游标函数,但一无所获。 有人对此有任何解释以及我可以做些什么来解决它吗?任何帮助将不胜感激。

After messing around a little with making a GUI with the Windows API, I recently realized a problem with the cursor. When I compile and run my application, it shows a window like its supposed to. When I drag my cursor from the left side of my screen into my applications window, as it goes over the border it becomes the <-> thing for resizing but it remains like that anywhere inside my window. Same goes for if I bring it into the window from the bottom. The problem does not exist when I do from the right side though. I questioned if it was just my program so I went to the MSDN website and even compiled and tried their program (http://msdn.microsoft.com/en-us/library/ff381409%28v=VS.85%29.aspx). Same Problem! So then I started experimenting with the WM_SETCURSOR message and cursor functions but got nowhere.
Does anyone have any explanation to this and what I could do to fix it? Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴意少年 2024-10-15 23:33:37

是的,该示例代码的行为正如您所描述的,因为 WNDCLASShCursor 成员设置为零,并且 WindowProc() 不处理WM_SETCURSOR

如果您想要始终使用相同的光标,那么在设置窗口类时最简单的做法是:

wc.hCursor = LoadCursor(0, IDC_ARROW);

如果您想对光标有更多控制,那么您需要离开 WNDCLASS::hCursor零并调用 SetCursor() 来响应 WM_SETCURSOR。您需要加载/创建各种光标,并通过某种方式根据应用程序的状态选择合适的光标。

Yes, that example code will behave as you describe because the hCursor member of WNDCLASS is set to zero, and WindowProc() doesn't handle WM_SETCURSOR.

If you want the same cursor all the time then it's easiest to do something like this when setting up your window class:

wc.hCursor = LoadCursor(0, IDC_ARROW);

If you want to have more control over the cursor then you want to leave WNDCLASS::hCursor zero and call SetCursor() in response to WM_SETCURSOR. You'll need to load/create your various cursors, and have some way of choosing the appropriate one based on your application's state.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文