test/testnativew32.c
author Sam Lantinga <slouken@libsdl.org>
Thu, 20 Jan 2011 18:04:05 -0800
changeset 5062 e8916fe9cfc8
parent 3071 6f3308d4b6cd
child 5535 96594ac5fd1a
permissions -rw-r--r--
Fixed bug #925

Changed "win32" to "windows"
slouken@3057
     1
slouken@3057
     2
#include "testnative.h"
slouken@3057
     3
slouken@5062
     4
#ifdef TEST_NATIVE_WINDOWS
slouken@3057
     5
slouken@5062
     6
static void *CreateWindowNative(int w, int h);
slouken@5062
     7
static void DestroyWindowNative(void *window);
slouken@3057
     8
slouken@5062
     9
NativeWindowFactory WindowsWindowFactory = {
slouken@5062
    10
    "windows",
slouken@5062
    11
    CreateWindowNative,
slouken@5062
    12
    DestroyWindowNative
slouken@3057
    13
};
slouken@3057
    14
slouken@3071
    15
LRESULT CALLBACK
slouken@3071
    16
WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
slouken@3060
    17
{
slouken@3071
    18
    switch (msg) {
slouken@3071
    19
    case WM_CLOSE:
slouken@3071
    20
        DestroyWindow(hwnd);
slouken@3060
    21
        break;
slouken@3071
    22
    case WM_DESTROY:
slouken@3071
    23
        PostQuitMessage(0);
slouken@3060
    24
        break;
slouken@3071
    25
    default:
slouken@3071
    26
        return DefWindowProc(hwnd, msg, wParam, lParam);
slouken@3060
    27
    }
slouken@3060
    28
    return 0;
slouken@3060
    29
}
slouken@3057
    30
slouken@3057
    31
static void *
slouken@5062
    32
CreateWindowNative(int w, int h)
slouken@3057
    33
{
slouken@3060
    34
    HWND hwnd;
slouken@3060
    35
    WNDCLASS wc;
slouken@3060
    36
slouken@3071
    37
    wc.style = 0;
slouken@3071
    38
    wc.lpfnWndProc = WndProc;
slouken@3071
    39
    wc.cbClsExtra = 0;
slouken@3071
    40
    wc.cbWndExtra = 0;
slouken@3071
    41
    wc.hInstance = GetModuleHandle(NULL);
slouken@3071
    42
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
slouken@3071
    43
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
slouken@3071
    44
    wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
slouken@3071
    45
    wc.lpszMenuName = NULL;
slouken@3060
    46
    wc.lpszClassName = "SDL Test";
slouken@3060
    47
slouken@3071
    48
    if (!RegisterClass(&wc)) {
slouken@3060
    49
        MessageBox(NULL, "Window Registration Failed!", "Error!",
slouken@3071
    50
                   MB_ICONEXCLAMATION | MB_OK);
slouken@3060
    51
        return 0;
slouken@3060
    52
    }
slouken@3060
    53
slouken@3071
    54
    hwnd =
slouken@3071
    55
        CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
slouken@3071
    56
                     CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL),
slouken@3071
    57
                     NULL);
slouken@3071
    58
    if (hwnd == NULL) {
slouken@3060
    59
        MessageBox(NULL, "Window Creation Failed!", "Error!",
slouken@3071
    60
                   MB_ICONEXCLAMATION | MB_OK);
slouken@3060
    61
        return 0;
slouken@3060
    62
    }
slouken@3060
    63
slouken@3060
    64
    ShowWindow(hwnd, SW_SHOW);
slouken@3060
    65
slouken@3060
    66
    return hwnd;
slouken@3057
    67
}
slouken@3057
    68
slouken@3057
    69
static void
slouken@5062
    70
DestroyWindowNative(void *window)
slouken@3057
    71
{
slouken@3071
    72
    DestroyWindow((HWND) window);
slouken@3057
    73
}
slouken@3057
    74
slouken@3057
    75
#endif