Skip to content

Instantly share code, notes, and snippets.

@cos-public
cos-public / main.cpp
Last active May 4, 2023 11:50
classic win32 app with raii style window
#include <Windows.h>
#include <cstdint>
template <typename WindowT, typename CtorArgs>
inline LRESULT CALLBACK window_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
if (message == WM_CREATE) {
::OutputDebugStringW(L"WM_CREATE\n");
auto cp = reinterpret_cast<LPCREATESTRUCTW>(lParam);
void * create_params = cp->lpCreateParams;
auto * args_tuple = reinterpret_cast<CtorArgs *>(cp->lpCreateParams); /// last parameter passed to ::CreateWindow()
@cos-public
cos-public / main.cpp
Last active May 2, 2023 11:57
minimal classic win32 application
#include <Windows.h>
#include <cstdint>
inline LRESULT CALLBACK main_window_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
if (message == WM_CREATE) {
::OutputDebugStringW(L"WM_CREATE\n");
}
if (message == WM_PAINT) {
::OutputDebugStringW(L"WM_PAINT\n");