Ver código fonte

Initial commit

Setup WinAPI.
master
TheoryOfNekomata 1 ano atrás
commit
60e5410eed
3 arquivos alterados com 58 adições e 0 exclusões
  1. +2
    -0
      .gitignore
  2. +6
    -0
      CMakeLists.txt
  3. +50
    -0
      src/main.c

+ 2
- 0
.gitignore Ver arquivo

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

+ 6
- 0
CMakeLists.txt Ver arquivo

@@ -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 Ver arquivo

@@ -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);
}

Carregando…
Cancelar
Salvar