A class-based program of mine is giving some issues, in the form of unhandled exceptions. To summarize the program:
The main class, graphcalc, functions perfectly. It is created on the stack. It creates a seperate thread, which then creates a window. In the creation procedure for this window, an instance of the second class, drawbox, is created dynamically. It is not deleted anywhere.
The problem occurs when trying to access member data/functions from member functions (other than the constructor). For example:
This function is non-static, and is a member of drawbox. hMain is likewise non-static and a member of drawbox.Code:LRESULT CALLBACK drawbox::WndProc(HWND hwnd , UINT msg,WPARAM wParam , LPARAM lParam) { hMain=hwnd; //access violation occurs here switch (msg) { case WM_PAINT: break; default: break; } return CallWindowProc (wpPrevProc , hwnd , msg , wParam , lParam); }
As far as I know, this function SHOULD have the 'this' pointer, but it would appear it thinks it does, but actually doesn't.
Any ideas as to whats going here?