Skip to content

Instantly share code, notes, and snippets.

@otya128
Last active September 4, 2018 14:39
Show Gist options
  • Save otya128/882003a13f18147b0af0998d4d9471d4 to your computer and use it in GitHub Desktop.
Save otya128/882003a13f18147b0af0998d4d9471d4 to your computer and use it in GitHub Desktop.
#undef _UNICODE
#include <windows.h>
HINSTANCE hInstance;
BOOL init;
LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp)
{
HWND child;
PAINTSTRUCT ps;
HDC hdc;
switch (msg)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 0, 0, "HELLO WORLD", 11);
EndPaint(hwnd, &ps);
return 0;
/*case WM_SHOWWINDOW: => success */
case WM_SIZE:
child = GetWindow(hwnd, GW_CHILD);
if (child)
MoveWindow(child, 0, 32, 100, 100, 0);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd , msg , wp , lp);
}
int WINAPI WinMain(HINSTANCE hInstance_, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS winc = {0};
HWND hwnd, child;
MSG msg;
hInstance = hInstance_;
winc.lpfnWndProc = WndProc;
winc.hInstance = hInstance;
winc.hCursor = LoadCursor(NULL , IDC_ARROW);
winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
winc.lpszClassName = "test";
RegisterClass(&winc);
hwnd = CreateWindow("test", "", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 200, 100, NULL, NULL, hInstance, NULL);
child = CreateWindow("test", "", WS_VISIBLE | WS_CHILD,
0, 0, 0, 0, hwnd, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
while (GetMessage(&msg , NULL , 0 , 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment