Pārlūkot izejas kodu

Initial commit

Setup WinAPI.
master
TheoryOfNekomata pirms 1 gada
revīzija
60e5410eed
3 mainītis faili ar 58 papildinājumiem un 0 dzēšanām
  1. +2
    -0
      .gitignore
  2. +6
    -0
      CMakeLists.txt
  3. +50
    -0
      src/main.c

+ 2
- 0
.gitignore Parādīt failu

@@ -0,0 +1,2 @@
.idea/
cmake-build-debug/

+ 6
- 0
CMakeLists.txt Parādīt failu

@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.24)
project(cerberus C)

set(CMAKE_C_STANDARD 11)

add_executable(cerberus WIN32 src/main.c)

+ 50
- 0
src/main.c Parādīt failu

@@ -0,0 +1,50 @@
#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR pCmdLine, int nCmdShow) {

MSG msg;
HWND hwnd;
WNDCLASSW wc = {
.style = CS_HREDRAW | CS_VREDRAW,
.cbClsExtra = 0,
.cbWndExtra = 0,
.lpszClassName = L"Window",
.hInstance = hInstance,
.hbrBackground = GetSysColorBrush(COLOR_3DFACE),
.lpszMenuName = NULL,
.lpfnWndProc = WndProc,
.hCursor = LoadCursor(NULL, IDC_ARROW),
.hIcon = LoadIcon(NULL, IDI_APPLICATION),
};

RegisterClassW(&wc);
hwnd = CreateWindowW(wc.lpszClassName, L"Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 350, 250, NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);

while (GetMessage(&msg, NULL, 0, 0)) {
DispatchMessage(&msg);
}

return (int) msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam) {

switch(msg) {

case WM_DESTROY:

PostQuitMessage(0);
break;
}

return DefWindowProcW(hwnd, msg, wParam, lParam);
}

Notiek ielāde…
Atcelt
Saglabāt