GDI Documentation

Introduction

The Windows Graphics Device Interface (GDI) provides a set of functions for drawing graphics, formatting text, and managing fonts and palettes. This documentation covers the core concepts, functions, structures, and best practices for using GDI in native Windows applications.

Key Concepts

Quick Start

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmd, int nShow){
    HWND hwnd = CreateWindowEx(0, L"STATIC", L"GDI Demo",
                               WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                               100,100,400,300, NULL, NULL, hInst, NULL);
    HDC hdc = GetDC(hwnd);
    HPEN hPen = CreatePen(PS_SOLID, 2, RGB(0,0,255));
    SelectObject(hdc, hPen);
    MoveToEx(hdc, 50,50,NULL);
    LineTo(hdc, 200,200);
    DeleteObject(hPen);
    ReleaseDC(hwnd, hdc);
    MSG msg;
    while(GetMessage(&msg,NULL,0,0)){
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}