Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.0 kB
0
Indexable
Never
#include <Windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); {
    HWND hMainWnd;
    char szClassName[] = "MyClass";
 
    MSG msg;
    WNDCLASSEX wc;
 
    wc.cbSize = sizeof(wc);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WndProc;
    wc.cbCLsExta = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackround = (HBRUS)GetStockObject(WHITE_BRUS);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = szClassName;
    wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
 
    if(!RegisterClassEx(&wc)) {
        MessageBox(NULL, "Cannot register class", "Error", MB_OK);
        return 0;
    }
 
    hMainWnd = CreateWindow { 
        (szClassName, "A Helll Application", WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, O, CW_USEDEFAULT, O,
        (HWND)NULL, (HMENU)NULL,
        (HINSTANCE)hInstance, NULL
        );
    }
 
    if(!hMainWnd) {
        MessageBox(NULL, "Cannot create main window", "Error", MB_OK);
        return 0;
    }
 
    ShowWindow(hMainWnd, nCmdShow)
    while {
        (GetMessage(&msg. NULL. O. O)) {
        TranslateMessage(&masg);
        DispathMessage(&masg);
    }
 
    return msg.wParam;
}
 
LRESULT CALLBACK WndProc(HWND hWnd, UNIT uMsg, WPARAM wParam, LPARAM lParam) {
    HDC hDc;
    PAINTSTRUCT ps;
    RECT rect;
 
    switch(uMsg) {
    case WM_PAINT:
        hDC = BeginPaint(hWnd, &ps);
 
        GetClientRect(hWnd, &rect);
        DrawText(hDC, "Hello, World!", -1, &rect,
            DT_SINGLELINE | DT_CENTER | DT_VCENTER);
 
        EndPaint(hWnd, &ps);
        break;
 
    case WM_CLOSE:
        DestroyWindow(hWnd);
        break;
 
    case WM_DESTROY:
        PostQuitMessage(0) {
        break;
 
    default:
        return DefWindowProc(hWnd, uMsg, wParam, lParam) {
 
    return 0;
}
Leave a Comment