I feel a fool for even asking this question but I'm trying to move from console C programming to programming the windows api. I've been banging my head against the keyboard while reading Petzold. I've got a window, a button and when you click the button a message pops up. Now what I want is TWO buttons, one called hi and one called bye. when you click hi you get the message hello and when you click bye you get the message goodbye. Here's what I'm working on:
Code:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
static HWND hwndButton;
case WM_CREATE:
hwndButton = CreateWindow(
"BUTTON", // predefined class
"hi", // button text
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON , // styles
// Size and position values are given explicitly, because
// the CW_USEDEFAULT constant gives zero values for buttons.
50, // starting x position
60, // starting y position
50, // button width
20, // button height
hwnd, // parent window
NULL, // No menu
(HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),
NULL); // pointer not needed
break;
case WM_COMMAND :
MessageBox (NULL, TEXT ("hello."),
TEXT ("hello"), MB_ICONERROR) ;
I know how to put another button on the window, but from there I'm lost!