test/testnativew32.c
changeset 3060 4cf533f434d8
parent 3057 089a77aebb7d
child 3071 6f3308d4b6cd
     1.1 --- a/test/testnativew32.c	Mon Feb 09 06:28:45 2009 +0000
     1.2 +++ b/test/testnativew32.c	Mon Feb 09 06:41:49 2009 +0000
     1.3 @@ -12,17 +12,63 @@
     1.4      DestroyWindowWin32
     1.5  };
     1.6  
     1.7 -static Display *dpy;
     1.8 +LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
     1.9 +{
    1.10 +    switch(msg)
    1.11 +    {
    1.12 +        case WM_CLOSE:
    1.13 +            DestroyWindow(hwnd);
    1.14 +        break;
    1.15 +        case WM_DESTROY:
    1.16 +            PostQuitMessage(0);
    1.17 +        break;
    1.18 +        default:
    1.19 +            return DefWindowProc(hwnd, msg, wParam, lParam);
    1.20 +    }
    1.21 +    return 0;
    1.22 +}
    1.23  
    1.24  static void *
    1.25  CreateWindowWin32(int w, int h)
    1.26  {
    1.27 -    return NULL;
    1.28 +    HWND hwnd;
    1.29 +    WNDCLASS wc;
    1.30 +
    1.31 +    wc.style         = 0;
    1.32 +    wc.lpfnWndProc   = WndProc;
    1.33 +    wc.cbClsExtra    = 0;
    1.34 +    wc.cbWndExtra    = 0;
    1.35 +    wc.hInstance     = GetModuleHandle(NULL);
    1.36 +    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    1.37 +    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    1.38 +    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    1.39 +    wc.lpszMenuName  = NULL;
    1.40 +    wc.lpszClassName = "SDL Test";
    1.41 +
    1.42 +    if(!RegisterClass(&wc))
    1.43 +    {
    1.44 +        MessageBox(NULL, "Window Registration Failed!", "Error!",
    1.45 +            MB_ICONEXCLAMATION | MB_OK);
    1.46 +        return 0;
    1.47 +    }
    1.48 +
    1.49 +    hwnd = CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL), NULL);
    1.50 +    if(hwnd == NULL)
    1.51 +    {
    1.52 +        MessageBox(NULL, "Window Creation Failed!", "Error!",
    1.53 +            MB_ICONEXCLAMATION | MB_OK);
    1.54 +        return 0;
    1.55 +    }
    1.56 +
    1.57 +    ShowWindow(hwnd, SW_SHOW);
    1.58 +
    1.59 +    return hwnd;
    1.60  }
    1.61  
    1.62  static void
    1.63  DestroyWindowWin32(void *window)
    1.64  {
    1.65 +    DestroyWindow((HWND)window);
    1.66  }
    1.67  
    1.68  #endif