testnativeos2.c 1.7 KB

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