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
Alter Hase
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
C:\repos\kingsmind\Engine>cd C:\repos\kingsmind\Engine C:\repos\kingsmind\Engine>g++ -c -DBUILD Engine.h Window.h src/Window.cpp Window.h:9:14: Fehler: Variable »DLLAPI WINDOW« hat Initialisierung, aber unvoll ständigen Typ Window.h:9:14: Warnung: erweiterte Initialisierungsliste nur mit -std=c++0x oder -std=gnu++0x verfügbar [standardmäßig aktiviert] Window.h:11:2: Fehler: expected primary-expression before »private« Window.h:11:2: Fehler: expected »}« before »private« Window.h:11:2: Fehler: expected »,« or »;« before »private« Window.h:15:10: Fehler: »LRESULT« bezeichnet keinen Typ Window.h:16:2: Fehler: expected unqualified-id before »public« Window.h:29:1: Fehler: expected declaration before »}« token src/Window.cpp:3:20: schwerwiegender Fehler: Window.h: No such file or directory Kompilierung beendet. C:\repos\kingsmind\Engine>PAUSE Drücken Sie eine beliebige Taste . . . |
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 |
#ifndef ENG_H #define ENG_H // Includees #include <windows.h> #ifdef __cplusplus extern "C" { #endif // Defines #ifdef BUILD #define DLLAPI __declspec( dllexport ) #else #define DLLAPI __declspec( dllimport ) #endif // Includees of the engine #include "Window.h" #ifdef __cplusplus } #endif #endif // ENG_H |
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 |
#ifndef WIN_H #define WIN_H enum WindowState{ OPENED, CLOSED }; class DLLAPI WINDOW { private: HWND hWnd; // Handle to the window bool Opened; static LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); public: // Constructor // The constructor creates the Window it self, the message loop is started by exec. WINDOW( const char* pcTitle, const int* pnWidth, const int* pnHeight ); // See Constructor int exec(); void SetState( const WindowState* State ); // Others bool IsOpened(); }; #endif // WIN_H |
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 |
#ifndef WIN_C #define WIN_C #include "Engine.h" // Protected: LRESULT WINDOW::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ){ WINDOW* pWin = NULL; pWin = ( WINDOW* ) GetWindowLong( hWnd, GWL_USERDATA ); if( pWin == NULL ) return DefWindowProc( hWnd, msg, wParam, lParam ); switch( msg ):{ case WM_CLOSE:{ pWin->SetState( CLOSED ); return 0; } break; case WM_DESTROY:{ PostQuitMessage( 0 ); return 0; } case WM_CREATE:{ pWin->SetState( OPENED ); return 0; } break; } return DefWindowProc( hWnd, msg, wParam, lParam ); } // Constructor WINDOW::WINDOW( const char* pcTitle, const int* pnWidth, const int* pnHeight ){ WNDCLASSEX wc; // This is the "window class( STRUCTURE )" wc.cbSize = sizeof( WNDCLASSEX ); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = GetModuleHandle( NULL ); wc.hIcon = NULL; wc.hCursor = NULL; wc.hbrBackground= ( HBRUSH ) COLOR_WINDOW; wc.lpszMenuName = pcTitle; wc.lpszClassName= pcTitle; wc.hIconSm = NULL; if( !RegisterClassEx( & wc ) ){ MessageBox( NULL, "Failed to register Window Class! : RegisterClassEx", "Error", MB_OK ); return 0; } HWND hWnd = CreateWindowEx( NULL, "KingsMind 0.1", "KingsMind 0.1", WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, *pnWidth, *pnHeight, NULL, NULL, wc.hInstance, 0 ); ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); } // Other methods int WINDOW::exec(){ MSG* pMsg = new MSG; if( PeekMessage( hWnd, NULL, 0, 0 )){ TranslateMessage( pMsg ); DispatchMessage( pMsg ); } delete pMsg; return 0; } void WINDOW:SetState( const WindowState* State ){ // Ich nutze das Enum hier da es noch erweitert werden soll if( *State = WindowState::OPENED ) Opened = true; else if ( *State = WindowState::CLOSED ) Opened = false; else Opened = false; } bool WINDOW::IsOpened(){ return Opened; } #endif // WIN_C |
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »Techie« (21.06.2013, 21:16)
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Alter Hase
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Komplette Klassen mit __declspec(dllexport) exportieren zu können ist iirc ein Feature was es nur beim Microsoft C++ Compiler gibt.
Werbeanzeige