WindowProc trotz Definition nicht gefunden
-
Hallo C++ Programmierer,
der Compiler sagt mir: error C2065: 'WindowProc': nichtdeklarierter Bezeichner
Aber ich habe die Funktion definiert.#include "stdafx.h" #include "Test.h" #define WINDOW_CLASS_NAME L"Game Window" #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code)&0x8000)?1:0) #define KEYUP(vk_code) ((GetAsyncKeyState(vk_code)&0x8000)?0:1) // Globals HWND main_window_handle = NULL; HINSTANCE hinstance_app = NULL; // -------------- // --- System --- // -------------- int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { MSG msg; HWND hwnd; WNDCLASSEX winclass; winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); hinstance_app = hinstance; if (!RegisterClassEx(&winclass)) { return(0); } if (!(hwnd = CreateWindowEx(NULL, WINDOW_CLASS_NAME, L"My Game", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 800, 600, NULL, NULL, hinstance, NULL))) { return(0); } main_window_handle = hwnd; GameInit(); while(TRUE) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { break; } TranslateMessage(&msg); DispatchMessage(&msg); } GameMain(); } GameShutdown(); return(msg.wParam); } LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { HDC hdc; PAINTSTRUCT paintstruct; switch (msg) { case WM_CREATE: { return(0); } case WM_PAINT: { hdc = BeginPaint(hwnd, &paintstruct); EndPaint(hwnd, &paintstruct); return(0); } case WM_DESTROY: { PostQuitMessage(0); return (0); } } return (DefWindowProc(hwnd, msg, wparam, lparam)); } // --------------- // --- Methods --- // --------------- void GameInit() { } void GameMain() { if (KEYDOWN(VK_ESCAPE)) { SendMessage(main_window_handle, WM_CLOSE, 0, 0); } } void GameShutdown() { }
-
Vyax schrieb:
der Compiler sagt mir: error C2065: 'WindowProc': nichtdeklarierter Bezeichner
Aber ich habe die Funktion definiert.Du hast sie aber erst später definiert. Der Compiler liest streng von oben nach unten. Also entweder Reihenfolge vertauschen oder vorher deklarieren.