Sign in to follow this  
Tarpedoe81

Newbie Question with static pointer?

Recommended Posts

I'm using Visual C++ 2008 Express Edition, and using the book, "Programming Role-Playing Games with DirectX, by Jim Adams." And I'm having a problem with this static pointer. Here is the static pointer being initialized: /* static cApplication *g_pApplication = NULL; */ cApplication is the class that handles most of the Windows code. The class also has a default message procedure. g_pApplication is the class pointer. What I'm trying to do is overload the message procedure. Here is the overloaded message procedure code: /* static long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: PostQuitMessage(0); return 0; default: return g_pApplication->MsgProc(hWnd, uMsg, wParam, lParam); } } */ Here is the code for the default message procedure code: /* virtual long FAR PASCAL MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hWnd, uMsg, wParam, lParam); } */ When the code compiles, in the Output window, it shows this error: /* First-chance exception at 0x7c918fea in Game Files.exe: 0xC0000005: Access violation writing location 0x00000010. */ It still compiles, but I want to know why it prints out the exception. Also, I want to know if it's a good idea to use the static pointer or just have the static message procedure. Thanks.

Share this post


Link to post
Share on other sites
Instead of using FAR PASCAL macros, use CALLBACK.

FAR doesn't have much use anymore. I believe its got something to do with 16-bit operating systems. Also, CALLBACK does the same thing that PASCAL does however the MSDN documentation specifies LRESULT CALLBACK WndProc (...) not FAR PASCAL.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this