-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
// src/main.cpp | ||
#include "main.hpp" | ||
#include <stdio.h> | ||
#include <windows.h> | ||
|
||
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { | ||
switch (uMsg) { | ||
case WM_DESTROY: { | ||
PostQuitMessage(0); | ||
return 0; | ||
} | ||
case WM_PAINT: { | ||
PAINTSTRUCT ps; | ||
HDC hdc = BeginPaint(hwnd, &ps); | ||
FillRect(hdc, &ps.rcPaint, (HBRUSH)(COLOR_WINDOW + 1)); | ||
DrawText(hdc, "Hello World", 11, &ps.rcPaint, 0); | ||
EndPaint(hwnd, &ps); | ||
return 0; | ||
} | ||
} | ||
return DefWindowProc(hwnd, uMsg, wParam, lParam); | ||
} | ||
|
||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR /*pCmdLine*/, int nCmdShow) { | ||
WNDCLASS wc = { }; | ||
|
||
wc.lpfnWndProc = WindowProc; | ||
wc.hInstance = hInstance; | ||
wc.lpszClassName = "Sample Window Class"; | ||
|
||
RegisterClass(&wc); | ||
|
||
HWND hwnd = CreateWindowEx(0, "Sample Window Class", "Win32 Hello World", | ||
WS_OVERLAPPEDWINDOW, 400, 400, 400, 400, | ||
NULL, NULL, hInstance, NULL); | ||
|
||
ShowWindow(hwnd, nCmdShow); | ||
|
||
MSG msg = { }; | ||
while (GetMessage(&msg, NULL, 0, 0)) { | ||
TranslateMessage(&msg); | ||
DispatchMessage(&msg); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
printf("Hello World\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters