Thread: Win32 class woes

  1. #1
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630

    Win32 class woes

    Ok, i created a class CWindow, got it running perfectly no problems there. The problem is when i derive a class from it say, CAppWindow. Well I have a function create in both classes that is virtual, since the CreateWindowEx function has to put (void*)this into the LPARAM lplparam to pass to WndPrco I was wondering if I can just do CWindow::Create() or do I have to write the function for the derived class over? Or is it safe to call the bass class's create function? I guess in other words it what im saying is when i call the base class CWindow::Create() is it going to pass a this* to the base class or a this* to the derived class? Ex:

    void CWindow::Create()
    { if(!bInitFail)
    { hWnd = CreateWindowEx(WS_EX_APPWINDOW,
    "CWINDOW",
    "Window!",
    WS_OVERLAPPED | WS_SYSMENU,
    50,
    50,
    300,
    200,
    NULL,
    NULL,
    hInst,
    (void*)this);
    }
    if(!hWnd)
    { bInitFail = true;
    MessageBox(NULL,"Error Creating Window","ERROR IN APPLICATION STARTUP",MB_OK);
    }

    so if i do:

    void CAppWindow::Create()
    { CWindow::Create();
    }

    Will the this* be of the base class or the derived class?
    Last edited by xds4lx; 02-22-2002 at 01:08 AM.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Yes - c++ polymorphism ensures the correct this ptr is used.

  3. #3
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Sweet! Thats what I thought but I really didnt want to go pull out one of my books from my book case, I was starting to like those webs growing on them lol. (been remembering everything but too much stress from first having a gf who gets diagnosed w/ cancer, then having her dump you a month later for no reason makes u forget a lot)
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. class composition constructor question...
    By andrea72 in forum C++ Programming
    Replies: 3
    Last Post: 04-03-2008, 05:11 PM
  3. Read-only class members
    By kidburla in forum C++ Programming
    Replies: 4
    Last Post: 10-14-2006, 12:52 PM
  4. Replies: 8
    Last Post: 07-24-2006, 08:14 AM