Results 1 to 1 of 1

Thread: [Advice please?]Object Wrapper classes

Threaded View

  1. #1

    Thread Starter
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    [Advice please?]Object Wrapper classes

    Howdy all,

    I'm still in the process of learning properly how this sorta thing works. I'm really just looking for advice.

    So far, I've made a wrapper for windows and buttons. This is all working nicely.

    What I want to know is, if I'm deleting everything thats necessary.

    To create a window, I do this:
    Code:
    CForm *Form1;
    Form1 = new CForm("Classname","Window Text",WS_OVERLAPPEDWINDOW|WS_VISIBLE,&dimensions,g_hInstance);
    Form1->Show();
    To have a "parent", I've kinda made it ugly and all that happens is a static HWND in the CForm class holds the handle of the first window created. If any window recieves WM_DESTROY, I first check if its the parent window, before calling PostQuitMessage(). Is this an ok approach? Before calling PQM(), should I be deleting anything else? Or will the destructor of all the objects be called automatically? I do also have a Dispose method in the CForm class, which basically just sends WM_DESTROY to the window.

    I also have a button wrapper, which uses a properties template I found on the internet. I would appreciate if anyone could explain a template in more detail for me, as everything I've found so far isn't all that in-depth.

    To place a button on a window, I do this:
    Code:
    CForm *Form1;
    CButton *button1;
    Form1 = new CForm("Classname","Window Text",WS_OVERLAPPEDWINDOW|WS_VISIBLE,&dimensions,g_hInstance);
    Form1->Show();
    button1 = new CButton();
    button1->Visible = TRUE;
    button1->Font = "Comic Sans MS";
    button1->FontSize = 8;
    button1->Text = "CLICK ME!";
    Now, the destructor of a button deletes the font created while changing the font of the button, using DeleteObject. Is this all that needs deleting?

    I guess I'm just looking for guidance in this area.

    Cheers in advance,

    chem
    Last edited by chemicalNova; Nov 7th, 2006 at 08:47 PM.

    Visual Studio 6, Visual Studio.NET 2005, MASM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width