Win32 class woes

This is a discussion on Win32 class woes within the Windows Programming forums, part of the Platform Specific Boards category; Ok, i created a class CWindow, got it running perfectly no problems there. The problem is when i derive a ...

  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, 09:18 PM
  2. class composition constructor question...
    By andrea72 in forum C++ Programming
    Replies: 3
    Last Post: 04-03-2008, 06:11 PM
  3. Read-only class members
    By kidburla in forum C++ Programming
    Replies: 4
    Last Post: 10-14-2006, 01:52 PM
  4. Replies: 8
    Last Post: 07-24-2006, 09:14 AM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 02:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21