Atlas - testnativew32.c
Home / ext / SDL / test Lines: 1 | Size: 2128 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 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_WINDOWS 16 17#include <windows.h> 18 19static void *CreateWindowNative(int w, int h); 20static void DestroyWindowNative(void *window); 21 22NativeWindowFactory WindowsWindowFactory = { 23 "windows", 24 CreateWindowNative, 25 DestroyWindowNative 26}; 27 28LRESULT CALLBACK 29WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 30{ 31 switch (msg) { 32 case WM_CLOSE: 33 DestroyWindow(hwnd); 34 break; 35 case WM_DESTROY: 36 PostQuitMessage(0); 37 break; 38 default: 39 return DefWindowProc(hwnd, msg, wParam, lParam); 40 } 41 return 0; 42} 43 44static void * 45CreateWindowNative(int w, int h) 46{ 47 HWND hwnd; 48 WNDCLASS wc; 49 50 wc.style = 0; 51 wc.lpfnWndProc = WndProc; 52 wc.cbClsExtra = 0; 53 wc.cbWndExtra = 0; 54 wc.hInstance = GetModuleHandle(NULL); 55 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 56 wc.hCursor = LoadCursor(NULL, IDC_ARROW); 57 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 58 wc.lpszMenuName = NULL; 59 wc.lpszClassName = TEXT("SDL Test"); 60 61 if (!RegisterClass(&wc)) { 62 MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"), 63 MB_ICONEXCLAMATION | MB_OK); 64 return 0; 65 } 66 67 hwnd = 68 CreateWindow(TEXT("SDL Test"), TEXT(""), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 69 CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL), 70 NULL); 71 if (!hwnd) { 72 MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"), 73 MB_ICONEXCLAMATION | MB_OK); 74 return 0; 75 } 76 77 ShowWindow(hwnd, SW_SHOW); 78 79 return hwnd; 80} 81 82static void 83DestroyWindowNative(void *window) 84{ 85 DestroyWindow((HWND)window); 86} 87 88#endif 89[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.