Wednesday, February 20, 2008

GETMESSAGE, TRANSLATEMESSAGE and DispatchMessage Function

GETMESSAGE FUNCTION :


GetMessage () function gets messages from MSG structure.

The syntax of the function goes this way.

BOOL GetMessage (LPMSG lpMsg, HWND hWnd, WORD w1, WORD w2)

This function returns Boolean value.





PARAMETERS:

LPMSG lpMsg = It will specify the address of the MSG structure where this function should go to fetch the messages.

LPMSG stands for long pointer to MSG structure.

HWND hWnd = It is the handle to the window receiving messages.

WORD w1 and WORD w2 = They specify the lowest and highest value message to receive.

They are always set to 0.

After receiving messages, these messages should be translated into code which applications can understand.

So, we have a function called translate function to do the task of translating.

TRANSLATEMESSAGE FUNCTION:

The syntax of this function is as follows

TranslateMessage (MSG &msg.)

This function will take only one parameter that is address of the msg. structure.

This function is required only to interact with the keyboard.

After translating the messages, the messages should be processed.

Inorder to process the messages, they should be redirected or sent to the function which will do the job of processing.

We have a function called dispatch message function to do this task.

DISPATCHMESSAGE FUNCTION:

This function is used to send messages to appropriate processing function.

The syntax of this function is

DispatchMessage (MSG &msg.)

This function takes one parameter that is address to the MSG structure.

This function gets the name of the processing function from the second member variable of the WNDCLASS structure.

There are few functions, which do the job of processing the messages.

One of them is ProcessMessagefn.

No comments: