Sign in to follow this  
anonuser

Visual Studio 2005 Oddities.

Recommended Posts

anonuser    148
Well I was starting a new project and its just a typical win32 project. I always go empty on settings with no links to MFC or ATL, I set those up by hand if I need them. Well out of laziness I was going to use a Dialog as my window and I had it all designed out and I do the wrap my win32 stuff inside the class thing. so it look something like this // note static is only in the prototype its just her to let you know NOTE: lParam should be a pointer to this. and DlgProc is the internal proc that has full access to a class. I like this method it gives me the entire class inside of all the win32 stuff. Which is great.
static BOOL CALLBACK CWindow::stDlgProc(...) {
    //assume msg is the proper variable
    //assume lParam is the proper variable
    //assume hwnd is the proper variable
    CWindow* pwinThis = NULL;

    if(msg == WM_INITDIALOG) {
         SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG)lParam);
         return TRUE;
    }

   pwinThis = GetWindowLongPtr(hwnd, GWLP_USERDATA);
  
   return pwinThis->DlgProc();
}


Now I didn't think much of this at first cause it did call DlgProc but only out of coincidence. pwinThis is actually NULL, visual studio can dereference it somehow, honestly I have no idea how. It should be throwing unhandled exceptions on dereferencing null but it doesn't until I try to acess this inside of DlgProc which is a private method in the class. The Debugger proved this was null but somehow I was inside of the right method. This was done from memory and should be accurate, but the problem is that the first message is not WM_INITDIALOG, or at least its not being passed to me. It's 48 in decimal but no idea which message that is in hex. Any ideas why or how I wouldn't be getting the WM_INITDIALOG message. My plan is to go back and just do a sandbox child window of my layout and place as a control on a regular window.

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