Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
// ########################################################################### // File: Main.cpp // Scribe: Stefan Falk // Description: Main // ########################################################################### // I N C L U D E S ########################################################### #include "Defs.hpp" // L I N K E R ############################################################### // P R O T O T Y P E S ####################################################### _w64 long __stdcall WndProc (HWND hwnd, unsigned int message, unsigned int wParam, _w64 long lParam); void shutdown (void); // G L O B A L ############################################################### bool run = true; // F U N C T I O N S ######################################################### // M a i n _ F u n c t i o n int __stdcall WinMain(HINSTANCE instance, HINSTANCE prevInstance, char* cmdLine, int show) { // Window class WNDCLASSEX wc; // Class name LPCWSTR ClassName = L"Win32 Window"; // Init window class ZeroMemory (&wc, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); // Size of window class in bytes wc.style = CS_HREDRAW | CS_VREDRAW; // Style of the window wc.lpfnWndProc = WndProc; // Adress for the window procedure wc.hInstance = instance; // Instance of the program wc.hCursor = LoadCursor (NULL, IDC_ARROW); // Standardcursor wc.lpszClassName = ClassName; // Classname // Register window class if (!RegisterClassEx (&wc)) return _ERROR; HWND hwnd; // Create window hwnd = CreateWindowEx (NULL, // No extended-style ClassName, // Window class L"Win32 Window", // Name of the window WS_OVERLAPPEDWINDOW, // Window-style 100, 100, // Position of the window (X, Y) 800, 600, // Size of the Window (W, H) NULL, // Handle to parent NULL, // Handle to menu instance, // Handle to instance of program NULL); // Pointer to window // If CreateWindowEx didn't succeed: Quit if (!hwnd) return _ERROR; // Show and update window ShowWindow (hwnd, SW_SHOW); UpdateWindow (hwnd); // Object for messages MSG msg; // Main-loop (Runs until run == false) while (run) { // Peek message if (PeekMessage (&msg, NULL, NULL, NULL, PM_REMOVE)) { // Message for quit? if (msg.message == WM_QUIT) run = false; // Translate and dispatch message TranslateMessage (&msg); DispatchMessage (&msg); } } // Set memory free shutdown (); // Set window class free UnregisterClass (wc.lpszClassName, wc.hInstance); // The end return (static_cast<int>(msg.wParam)); } // main() // Windoe procedure for messages _w64 long __stdcall WndProc (HWND hwnd, unsigned int msg, unsigned int wParam, _w64 long lParam) { // Provess message switch (msg) { // Key pressed case WM_KEYDOWN: { // If 'ESCAPE' has been pressed: Quit if (wParam == VK_ESCAPE) PostQuitMessage (0); } break; // Window shall be destroyed/closed case WM_DESTROY: case WM_CLOSE: { PostQuitMessage (0); } break; // Other messages won't be processed default : break; } // Go on return DefWindowProc (hwnd, msg, wParam, lParam); } // WndProc() void shutdown() { } // shutdown() |
Werbeanzeige