Skip to main content
GameDev.net gamedev.net
🔒 Locked

need help.

Started by mag Jul 8, 2004 at 7:34 PM 0 replies 750+ views
Original Post
mag
mag
I need help,I have been reading a book called game programming all in one,by Bruno Migeul Teixeira de Sousa.I am having a problem with getting the code for the reusable to work.I get errors.I fixed as many of them as i could,but I still have 10 left to deal with.if anyone could help me i would really appericate it.Here are the error's that i get.Below that is the code.As far as the Mirus.h error i tried to add that file,and i still get error's. the error's I have been getting. ----------------------------------------------------------------- 03 Main.cpp(5): fatal error C1083: Cannot open include file: 'Mirus.h': No such file or directory mrwindow.cpp(18): error C2143: syntax error : missing ';' before 'mrWindow::Create' mrwindow.cpp(18): error C2501: 'mrError32' : missing storage-class or type specifiers mrwindow.cpp(41): error C2065: 'mrErrorRegisterClass' : undeclared identifier mrwindow.cpp(50): error C2065: 'mrNoError' : undeclared identifier mrwindow.cpp(65): warning C4311: 'type cast' : pointer truncation from 'LPVOID' to 'long' mrwindow.cpp(69): warning C4312: 'type cast' : conversion from 'LONG' to 'mrWindow *' of greater size mrWindow.h(25): error C2146: syntax error : missing ';' before identifier 'Create' mrWindow.h(25): error C2501: 'mrWindow::mrError32' : missing storage-class or type specifiers mrWindow.h(28): warning C4183: 'Create': missing return type; assumed to be a member function returning 'int' ----------------------------------------------------------------- here are the header files. (source) // mrDatatypes.h // Include this file only once #pragma once // Basic type definitions typedef char mrInt8; typedef unsigned char mrUInt8; typedef short mrInt16; typedef unsigned short mrUInt16; typedef long mrInt32; typedef unsigned long mrUInt32; typedef int mrInt; typedef unsigned int mrUInt; typedef float mrReal32; typedef double mrReal64; // Composed definitions enum mrBool32 { mrFalse = 0, mrTrue = 1, mrBool32_Force32 = 0xFFFFFFFF }; (/source) ----------------------------------------------------------------- (source) //'mrError.h' // Include this file only once #pragma once // Error codes enum mrError32 { mrNoError = 0, mrError32_Force32 = 0xFFFFFFFF }; (/source) ----------------------------------------------------------------- (source) // 'mrWindow.h' // Mirus base types header #include "mrDatatypes.h" // Windows header file #include // Include this file only once #pragma once // Mirus window framdwork class mrWindow { protected: WNDCLASS m_kWndClass; HWND m_hWindow; MSG m_kMessage; public: // Constructor / Destructor mrWindow (void); ~mrWindow (void); // Window manipulation functions mrError32 Create (HINSTANCE hInstance, LPSTR szTitle, mrInt iWidth = CW_USEDEFAULT, mrInt iHeight = CW_USEDEFAULT, mrUInt32 istyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE); static LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam); void Run (void); // Custom functions virtual mrBool32 MessageHandler (UINT iMessage, WPARAM wParam, LPARAM lParam); virtual mrBool32 Frame (void) = 0; }; (/source) ----------------------------------------------------------------- (source) and here are the cpp files. //'mrWindow.cpp' // Complement header file #include "mrWindow.h" // Default constuctor mrWindow::mrWindow (void) { // do nothing } // Default destructor mrWindow::~mrWindow (void) { // Do nothing } // Create the window mrError32 mrWindow::Create (HINSTANCE hInstance, LPSTR szTitle, mrInt iWidth, mrInt iHeight, mrUInt32 istyle) { // Visiual properties m_kWndClass.hCursor = LoadCursor (NULL, IDC_ARROW); m_kWndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION); m_kWndClass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); // System properites m_kWndClass.hInstance = hInstance; m_kWndClass.lpfnWndProc = WndProc; m_kWndClass.lpszClassName = "Mirus Window"; // Extra properites m_kWndClass.lpszMenuName = NULL; m_kWndClass.cbClsExtra = NULL; m_kWndClass.cbWndExtra = NULL; m_kWndClass.style = NULL; // Try to Register class if (!RegisterClass (&m_kWndClass)) { return mrErrorRegisterClass; } // Create the Window m_hWindow = CreateWindow ("Mirus Window" , szTitle, istyle, CW_USEDEFAULT, CW_USEDEFAULT, iWidth, iHeight, NULL, NULL, hInstance, (void *) this); SetWindowText (m_hWindow, szTitle); return mrNoError; } // Normal message handler - direct messages to our own LRESULT CALLBACK mrWindow::WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam) { mrWindow * pkWindow = NULL; mrBool32 bProcessed = mrFalse; switch (iMessage) { // Window is creating - set custom information case WM_NCCREATE: SetWindowLong (hWindow, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams)); break; // Window message - Let our handler process it default: pkWindow = (mrWindow *) GetWindowLong (hWindow, GWL_USERDATA); if (NULL != pkWindow) { bProcessed = pkWindow->MessageHandler (iMessage, wParam, lParam); } break; } // Message not Processed - let windows handle it if (mrFalse == bProcessed) { return DefWindowProc (hWindow, iMessage, wParam, lParam); } return 0; } // Real time message loop void mrWindow::Run (void) { while (1) { // Querey to see if there is any message in the queue if (PeekMessage (&m_kMessage, m_hWindow, 0, 0, PM_REMOVE)) { // If it the WM_QUIT message, quit the loop if (WM_QUIT == m_kMessage.message) { break; } // process the message normally else { TranslateMessage (&m_kMessage); DispatchMessage (&m_kMessage); } } // No message, do frame else { Frame (); } } } // our message handler mrBool32 mrWindow::MessageHandler (UINT iMessage, WPARAM wParam, LPARAM lParam) { switch (iMessage) { // Close window case WM_CLOSE: PostQuitMessage (0); return mrTrue; break; // Not handled - let Windows handle default: return mrFalse; break; } } (/source) ----------------------------------------------------------------- (source) // '03 Main.cpp' // Mirus window framework header #include "Mirus.h" // Custom derived class class CustomWindow : public mrWindow { public: // Constructor / Destructor CustomWindow (void) {}; ~CustomWindow (void) {}; // Window manipulation functions mrBool32 Frame (void) {return mrTrue;} ; }; // "WinMain vs. main" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd) { // our window CustomWindow kWindow; // Create window kWindow.Create (hInstance, "03 Mirus Example"); // Enter message loop kWindow.Run (); } (/source)
DesCr
DesCr
Please edit your post with source and /source, both surrounded by [] instead of ().

Mirus.h needs to be in the same folder as the file that's attempting to use it. Which compiler are you using?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.