odcenter.c

来自「Windows 3.0 programming primer / Alan So」· C语言 代码 · 共 44 行

C
44
字号
HWND CreateODcenter(hInstance, nCmdShow, cx, cy)
HANDLE hInstance;
int nCmdShow;
int cx, cy;
{
    HWND hwnd;
    int x, y;
    int xDesktop, yDesktop;

    hInst = hInstance;

    /* Get dimensions of desktop (that is, screen) */

    xDesktop = GetSystemMetrics(SM_CXSCREEN);
    yDesktop = GetSystemMetrics(SM_CYSCREEN);

    /* Do simple calculations */

    x = (xDesktop - cx) / 2;
    y = (yDesktop - cy) / 2;

    /* Call CreateWindow with new dimensions */

    hwnd = CreateWindow(
        "SampleClass",
        "Sample Program",
        WS_OVERLAPPEDWINDOW,
        x,
        y,
        cx,
        cy,
        NULL,
        NULL,
        hInstance,
        NULL);

    if(!hwnd)
        return(FALSE);

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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?