ERLEDIGT
NEIN
NEIN
ANTWORTEN
4
4
ZUGRIFFE
243
243
EMPFEHLEN
-
Hallo Leute,
ich versuche seit einer woche DirectX 10 zu lernen, aber ich scheitere schon beim erzeugen eines einfachen Windows.
Hier ist mein sourcecode:
Code cpp: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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
#include <windows.h> #include <WindowsX.h> //GLOBALS //Alias zum Fenster HWND g_hWnd; LPCWSTR g_CLASSNAME = TEXT("PythagorasTree"); const bool g_FULLSCREEN = false; int g_ScreenWidth; int g_ScreenHeight; //Prototypes bool AssignApplicationAndCreateWindow(HWND& hWnd, HINSTANCE hInstance); // Unsere Callback-Funktion zum Auswerten der Fensternachrichten LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam); bool FullScreenMode(); bool RunWindow(); bool ShutDownWindow(HINSTANCE& hInstance); bool Error(LPCWSTR cmd); //Einstiegspunkt //hInstance: Alias zur Anwendung //hPrevInstance: Ehemaliger Alias //lpCmdLine: Kommandozeile //nShowCmd: die Art, wie das Fenster gestartet werden soll int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { if(!AssignApplicationAndCreateWindow(g_hWnd, hInstance)) { //Fehlermeldung } while(RunWindow()) { //Hauptschleife } if(!ShutDownWindow(hInstance)) { //Fehlermeldung } } bool ShutDownWindow(HINSTANCE& hInstance) { if(g_FULLSCREEN) { ChangeDisplaySettings(NULL, 0); } //DestroyWindow(g_hwnd); //g_hwnd = NULL; UnregisterClass(TEXT("PT"), hInstance); hInstance = NULL; return true; } bool AssignApplicationAndCreateWindow(HWND& hWnd, HINSTANCE hInstance) { // WNDCLASS-Struktur für die Applikationsbeschreibung für Windows füllen WNDCLASSEX wc; int posX, posY; posX = 0; posY = 0; ZeroMemory(&wc, sizeof(WNDCLASSEX)); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hIconSm = wc.hIcon; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = TEXT("PT"); wc.cbSize = sizeof(WNDCLASSEX); if(FAILED(RegisterClassEx(&wc))) { return Error(TEXT("Window could not be registered!")); } g_ScreenWidth = GetSystemMetrics(SM_CXSCREEN); g_ScreenHeight = GetSystemMetrics(SM_CYSCREEN); if(g_FULLSCREEN) { if(!FullScreenMode()) { //MessageBox(NULL, L"Could not Change Display Mode!", L"Fatal Error!", MB_ICONERROR); return Error(L"Could not Change Display Mode!"); } posX = posY = 0; } else { g_ScreenWidth = 800; g_ScreenWidth = 600; // Place the window in the middle of the screen. posX = (GetSystemMetrics(SM_CXSCREEN) - g_ScreenWidth) / 2; posY = (GetSystemMetrics(SM_CXSCREEN) - g_ScreenHeight) / 2; } hWnd = CreateWindow(WS_EX_APPWINDOW, g_CLASSNAME, g_CLASSNAME, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP, posX, posY, g_ScreenWidth, g_ScreenHeight, NULL, NULL, hInstance, NULL); if(hWnd == NULL) { //Fehlermeldung //MessageBox(NULL, L"Could not Change Display Mode!", L"Fatal Error!", MB_ICONERROR); return Error(L"Window could not be created!"); } ShowWindow(hWnd, NULL); SetForegroundWindow(hWnd); SetFocus(hWnd); return true; } bool FullScreenMode() { // The DEVMODE data structure contains information // about the initialization and environment of a printer // or a display device. DEVMODE dmScreenSettings; ZeroMemory(&dmScreenSettings, sizeof(DEVMODE)); //dmScreenSettings mit 0 initialisieren memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); //die Größe in Byte festlegen dmScreenSettings.dmSize = sizeof(dmScreenSettings); //Die Breite und Höhe des Ausgabegeräts in pixel angeben dmScreenSettings.dmPelsWidth = (unsigned long)g_ScreenWidth; dmScreenSettings.dmPelsHeight = (unsigned long)g_ScreenHeight; //Die Farbe in bits per pixel angeben dmScreenSettings.dmBitsPerPel = 32; dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; if(FAILED(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN))) { return false; } return true; } bool RunWindow() { MSG msg; ZeroMemory(&msg, sizeof(MSG)); if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); if(msg.message == WM_QUIT) return false; } return true; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if((msg == WM_DESTROY) || (msg = WM_CLOSE)) { PostQuitMessage(0); return 0; } if((msg == WM_KEYDOWN) && (wParam == VK_ESCAPE)) { PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, msg, wParam, lParam); } bool Error(LPCWSTR msg) { MessageBox(NULL, msg, L"Fatal Error!", MB_ICONERROR); return false; }
Wenn ich das Programm ausführen will, dann kommt beim Aufruf von CreateWindowEx(...) die folgende Fehlermeldung:
CXX0030: Error: expression cannot be evaluated
-
Hi
ich seh da im Code kein CreateWindowEx?
-
Die Meldung, die du angibst, ist ein Kompilier-Fehler.
Du benutzt CreateWindow, gibst aber Parameter an, als wäre es CreateWindowEx.
Ich sehe da noch was Anderes in einer WndProc:
if((msg == WM_DESTROY) || (msg = WM_CLOSE))
Da fehlt ein zweites = bei WM_CLOSE.
-
Ich habs mit CreateWindow und CreateWindowEx probiert...... kommt immer wieder dieselbe Fehlermeldung.
Kann mir bitte jemand den sourcecode so umändern, dass es fehlerfrei ausgeführt werden kann.
Danke
-
Danke an alle, Problem hat sich erledigt.
Ähnliche Themen
-
Was für ein Unterschied? Visual Basic vs Visual Studio
Von Mega-Zocker im Forum Visual Basic 6.0Antworten: 2Letzter Beitrag: 16.10.07, 11:41 -
Problem mit CreateWindowEx
Von nitgun im Forum VisualStudio & MFCAntworten: 5Letzter Beitrag: 25.03.07, 08:29 -
[eclipse] Problem mit Visual Editor & New Visual Class
Von GoLLuM im Forum JavaAntworten: 2Letzter Beitrag: 07.05.06, 22:13 -
Eine Frage im zusammenhang von Visual BASIC und Visual STUDIO
Von CodeControl im Forum Visual Basic 6.0Antworten: 1Letzter Beitrag: 29.09.04, 09:20 -
Hilfe bei Entscheidung: Visual Basic.net <-> Visual C++ .net
Von RamonR im Forum Visual Basic 6.0Antworten: 1Letzter Beitrag: 31.07.04, 10:58





Zitieren

Login






