C++记录鼠标释放

发布于 2025-01-06 07:02:55 字数 339 浏览 0 评论 0原文

我试图让一个程序在释放鼠标左键并且仅释放时写入文本文件。下面是我尝试过的代码。 GUI 中有一个滑块,用户可以前后移动来放大和缩小视频。我希望能够只获取用户停止的值。目前,它打印起始值和停止值以及其间的所有值。我认为让它在鼠标释放时打印停止值会起作用。目前它仍然只打印所有信息,而不仅仅是鼠标释放的信息。

if(WM_LBUTTONUP)
{
    myfile1.open("testing.txt", std::ios_base::app);
    myfile1 << "testing";
    myfile1 << "\n";
    myfile1.close();
}

I am trying to get a program to write to a text file when the left button on the mouse is released, and only released. Below is the code that I have tried. In the GUI there is a slider that the user can move back and forth to zoom in and out on a video with. I want to be able to grab just the value the user stops at. Currently it prints the starting and stopping values as well as all the values in between. I thought that getting it to print the stopping value on the mouse release would work. Currently it still just prints all the info not just on the mouse release.

if(WM_LBUTTONUP)
{
    myfile1.open("testing.txt", std::ios_base::app);
    myfile1 << "testing";
    myfile1 << "\n";
    myfile1.close();
}

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

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

发布评论

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

评论(1

千纸鹤带着心事 2025-01-13 07:02:55

您的条件始终为真,因为 WM_LBUTTONUP 是一个非零常量。您应该比较 WindowProc 回调

Your condition is always true because WM_LBUTTONUP is a non-zero constant. You should compare a uMsg == WM_LBUTTONUP in your WindowProc callback.

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