开发者

How do I link C++ (Visual Studio 2010) to an image-outputting event listener?

开发者 https://www.devze.com 2023-03-25 18:18 出处:网络
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 e开发者_运维百科xpected. For every key I press, I want an image (speci

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 e开发者_运维百科xpected. 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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消