1 /*
2   Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
3 
4   This software is provided 'as-is', without any express or implied
5   warranty.  In no event will the authors be held liable for any damages
6   arising from the use of this software.
7 
8   Permission is granted to anyone to use this software for any purpose,
9   including commercial applications, and to alter it and redistribute it
10   freely.
11 */
12 
13 #include "testnative.h"
14 
15 #ifdef TEST_NATIVE_OS2
16 
17 #define WIN_CLIENT_CLASS    "SDL Test"
18 
19 static void *CreateWindowNative(int w, int h);
20 static void DestroyWindowNative(void *window);
21 
22 NativeWindowFactory OS2WindowFactory = {
23     "DIVE",
24     CreateWindowNative,
25     DestroyWindowNative
26 };
27 
CreateWindowNative(int w,int h)28 static void *CreateWindowNative(int w, int h)
29 {
30     HWND    hwnd, hwndFrame;
31     ULONG   ulFrameFlags = FCF_TASKLIST | FCF_DLGBORDER | FCF_TITLEBAR |
32                            FCF_SYSMENU  | FCF_SHELLPOSITION |
33                            FCF_SIZEBORDER | FCF_MINBUTTON | FCF_MAXBUTTON;
34 
35     WinRegisterClass(0, WIN_CLIENT_CLASS, WinDefWindowProc,
36                      CS_SIZEREDRAW | CS_MOVENOTIFY,
37                      sizeof(ULONG)); /* We should have minimum 4 bytes. */
38 
39     hwndFrame = WinCreateStdWindow(HWND_DESKTOP, 0, &ulFrameFlags,
40                                    WIN_CLIENT_CLASS, "SDL Test", 0, 0, 1, &hwnd);
41     if (hwndFrame == NULLHANDLE) {
42         return NULL;
43     }
44 
45     WinSetWindowPos(hwndFrame, HWND_TOP, 0, 0, w, h,
46                     SWP_ZORDER | SWP_ACTIVATE | SWP_SIZE | SWP_SHOW);
47 
48     return (void *)hwndFrame;   /* We may return client or frame window
49                                    handle for SDL_CreateWindowFrom(). */
50 }
51 
DestroyWindowNative(void * window)52 static void DestroyWindowNative(void *window)
53 {
54     WinDestroyWindow((HWND) window);
55 }
56 
57 #endif /* TEST_NATIVE_OS2 */
58