Hi, this is my first win32 program and I'm making changes while I learn. I have a win32 window that needs functionality and I started looking into how to add buttons to your win32 program from here,
This is the first window I have I need a little advice as to how to add a button to start making it a program.
Code:
#include <windows.h>
LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM param, LPARAM lparam);
int WINAPI WinMain(HINSTANCE currentInstance, HINSTANCE previousInstance, PSTR cmdLine, int cmdCount)
{
// Register the window class
const char* CLASS_NAME = "m0nst3r";
WNDCLASS wc{};
wc.hInstance = currentInstance;
wc.lpszClassName = CLASS_NAME;
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpfnWndProc = WindowProcessMessages;
RegisterClass(&wc);
// Create the window
CreateWindow(CLASS_NAME, "Windows Look e-Tr0n",
WS_OVERLAPPEDWINDOW | WS_VISIBLE, // Window style
CW_USEDEFAULT, CW_USEDEFAULT, // Window initial position
800, 600, // Window size
0, 0, 0, 0);
// Window loop
MSG msg{};
while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM param, LPARAM lparam) {
switch (msg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd, msg, param, lparam);
}
}