Im teaching myself the Win32 API, so im messing around learning functions and what not. So how do I change the text on the button if it is clicked? I cant figure it out. Thanks
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
const int ID_TIMER = 1;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASS win;
MSG message;
HWND main;
HWND button1;
win.cbClsExtra = 0;
win.cbWndExtra = 0;
win.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
win.hCursor = LoadCursor(NULL, IDC_ARROW);
win.hIcon = NULL;
win.hInstance = hInstance;
win.lpfnWndProc = WndProc;
win.lpszClassName = TEXT("MAIN");
win.lpszMenuName = 0;
win.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&win);
main = CreateWindow(TEXT("MAIN"), TEXT("BitMap"), WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL, hInstance, NULL);
button1 = CreateWindow(TEXT("BUTTON"), TEXT("Button"), WS_CHILD | WS_VISIBLE, 10, 10, 50, 50, main, NULL, hInstance, NULL);
ShowWindow(main, nShowCmd);
while(GetMessage(&message, NULL, 0, 0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
UINT timer;
timer = SetTimer(hwnd, ID_TIMER, 1000, NULL);
break;
case WM_TIMER:
SendMessage(hwnd, WM_SETTEXT, 0,(LPARAM)TEXT("Testing Timer"));
break;
case WM_COMMAND:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}