Windows programming notes 4

Source: Internet
Author: User
Tags printable characters

1. There are two steps to process a Keyboard Message: Save the message in the system message queue and put the messages in the application message queue for synchronization. Considering that keyboard input leads to window focus switching, if you put it directly in the application message queue, the window after switching may no longer receive keyboard input.
2. For key combinations that generate printable characters, window will generate a key-hitting message and a character message. For keys that do not generate a character, only a key-hitting message will be generated.
3. wm_keydown may be sent again. wm_keyup occurs only once each time the key is clicked.
4. For all key-hitting messages, wparam is the code that indicates the key to be pressed or released, while lparam contains other data of the key.

5. function key judgment.
Istate = getkeystate (vk_shift );
Istate = getkeystate (vk_capital); // view the status based on the isate location.
6. Reasonable keyboard operations should be performed based on wm_char, wm_deadchar, wm_syschar, and wm_stsdeadchar. wm_keydown messages may cause errors due to differences in keyboard layout. The translatemessage message generates a character message from the wm_keydown message. The wm_char message is clipped between the hit key message. Deadkey can basically be ignored.
For example, the order of messages generated when the key is used is wm_keydown | wm_char | wm_keyup.
7. Rules: If you want to read the keyboard characters entered in the window, process the wm_char message. If you want to read the cursor key and function key, process the wm_keydown message.
8. Insert operator function.
Createcaret, setcaretpos, showcaret, hidecaret, destroycaret, getcaretpos, getcaretblinktime, and setcaretblinktime
A Message Queue supports only one insert character. Therefore, you should not create a caret in the create window to avoid multiple windows. Caret can be easily understood only when the focus is obtained ~~
Hidecaret is accumulative. That is to say, it is necessary to show the number of hide times before launching caret...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.