First, handling a button click/press. The lower-level handling is already done by the button's Windows class. The message
WM_COMMAND
is sent to its parent window. Please see:
Button Messages (Windows)[
^].
"When the user clicks a button, its state changes, and the button sends notification codes, in the form of
WM_COMMAND
messages." Look at any page on notification code. You will see that
wParam
(32 bits) contains the button's control identifier as the lower word and notification code as the higher word, and
lParam
contains a handle to a button (check box, in your case).
This way, you can capture the message and handle it. You already started to do it, only you have to remove bad code, such as
case 1
; generally, always remove all hard-coded
immediate constants. Remember that other controls can send the same message, so you have to identify them as described above.
Now, you can read the content of text input control by sending it a message
WM_GETTEXT
:
WM_GETTEXT message (Windows)[
^],
SendMessage function (Windows)[
^].
Organize your logic depending on results. Again, avoid hard-coded
magic strings. That's all.
Just few notes on your work. It's good that you exercise pure raw Windows API development; it helps to understand how things development. But people hardly use raw API, which is not object-oriented, for development of application. Rather, they use it for development of object-oriented libraries which wrap both basic Windows mechanisms, such as message sending, posting and handling, as well as many Windows classes. Such intermediate product save a lot of time and just pointless "manual" labor. If you use some available library, this is one thing, but if you don't use anything 3rd-party, I can understand it, too. Then your own object-oriented library can save a lot of development time and boring labor, unless if you plan to develop just 1-2 applications. :-)
—SA