SendMessage/PostMessage Constants (Updated Version with numeric constant values)
Last week we had a short intro to SendMessage and PostMessage
API functions. There are thousands of messages used throughout Windows.
Command buttons, edit controls (text boxes) and many other controls have
their own set of messages they can send and receive. This week we will go
deeper into this topic and have a look at some of the most popular and
interesting Windows messages, that is, messages sent by Windows
operating system to Your application.
wParam - ASCII value for the key you
wish to send
In this example system sends a letter "V" to a text box named txtText. Using a txtText.hwnd you tell the system which control should receive the message. WM_CHAR describes the message, and wParam and lParam were described earlier. Just remember, before You use any of the API functions, declare them either in class module as public or in declaration section of a form as private. You also need to declare constants You are using in the function. (in this case it is WM_CHAR). To get the declaration of SendMessage, look at API Viewer or copy from last weeks article.
Constant's declaration: Private or Public Const WM_COPY = &H301
Note: lParam and wParam have to be set to 0 and before executing the code, the text inside the text box has to be selected.
Declaration: Private/Public Const WM_PASTE = &H302
Declaration: Private/Public Const WM_UNDO = &H304
WM_COPY, WM_CUT, WM_PASTE, and WM_UNDO are very helpful when you are writing your own text editor. The following next three message types are more useful to manipulate a window.
Declaration: Private/Public Const WM_SETTEXT = &HC
Declaration: Private/Public Const WM_QUIT = &H12
Created By Laimonas Simutis. 2001. firstname.lastname@example.org