Use message crackers to simplify message ing

Source: Internet
Author: User

Message crackers is a group of macros that encapsulate message ing provided by Platform SDK. It must contain header files.Windowsx. h.

The traditional message ing uses a large switch... case combination.CodeVery bloated. The framework of MFC solves this problem well, but sometimes we want to use only sdks for development. Using the macros provided by message crackers is a good choice.

Handle_msg macro for message ing
Lresult callback mainwndproc (hwnd, uint MSG, wparam,
Lparam)
{
Switch (MSG)
{
Handle_msg (hwnd, wm_command, oncommand );
Handle_msg (hwnd, wm_keyup, onkeyup );
Handle_msg (hwnd, wm_close, onclose );
Handle_msg (hwnd, wm_destroy, ondestroy );
Default: Return defwindowproc (hwnd, MSG, wparam, lparam );
}
}

In addition, when using the sendmessage and postmessage functions, You need to integrate multiple parameters into the wparam and lparam parameters. For example

Sendmessage (hwndparent, wm_command,
Makewparam (idc_userctl, bn_dblclk ),
(Lparam) getdlgitem (hwnd, id_userctl ));

However, message crackers provides the forward_wm_command macro. The preceding operations are simplified
Forward_wm_command (hwndparent, idc_userctl,
Getdlgitem (hwnd, id_userctl ),
Bn_dblclk, sendmessage );

In addition, message crackers also provides some control-related macros, such
# Define listbox_enable (hwndctl, fenable) enablewindow (hwndctl), (fenable ))

# Define listbox_getcount (hwndctl) (INT) (DWORD) sndmsg (hwndctl), lb_getcount, 0l, 0l ))

Finally, I want to mention that there is a tool calledMessage cracker wizard, which works with message ing macros, can be downloaded at http://www.codeproject.com/kb/winsdk/ms?ackwizard.aspx

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.