如何链接 C++ (Visual Studio 2010) 到图像输出事件侦听器?

发布于 2024-11-27 13:12:57 字数 143 浏览 2 评论 0原文

我正在用 C++ 编写一个非常简单的程序来监听键盘输入,但是我想要输出的内容比我预期的要困难得多。对于我按下的每个键,我希望屏幕上出现一个图像(特定于该键)。例如,假设如果我按“O”键,地球的图像就会出现在我的屏幕上。

实现这一目标的最佳方法是什么?谢谢!

I am writing a very simple program in C++ that listens to keyboard input, but what I want to output is much more difficult than I expected. For every key I press, I want an image (specific to the key) to appear on the screen. For example, let's say if I press the "O" key, an image of Earth appears on my screen.

What's the best way to achieve this? Thanks!

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

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

发布评论

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

评论(1

迎风吟唱 2024-12-04 13:12:57

这可以通过分层窗口实现。我创建了一个 Win32 项目作为演示。您可以在此处找到代码和说明

基本上,您必须:

  • 处理 WM_CHAR 消息并加载适当的图像(从资源或从磁盘)
  • 创建一个分层窗口并在该窗口中显示加载的图像
  • 如果您想在最后一个键按下后的给定时间间隔后自动关闭窗口按你必须创建一个计时器,并在定时程序中销毁窗口

检查我的链接以获取问题的解决方案。

This is possible with layered windows. I have created a Win32 project as a demo. You can find the code and explanations here.

Basically you have to:

  • handle the WM_CHAR message and load the appropriate image (from resources or from disk)
  • create a layered window and display the loaded image in that window
  • if you want to automatically close the window after an given interval after the last key was pressed you have to create a timer and in the timed procedure destroy the window

Check my link for a solution to your problem.

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