How do I link C++ (Visual Studio 2010) to an image-outputting event listener?
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.
精彩评论