Dynamic Creation of an object

This is a discussion on Dynamic Creation of an object within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I have this SDI program with a CFormView class. This object creates a tab control object CTabControl which is ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    205

    Dynamic Creation of an object

    Hi,
    I have this SDI program with a CFormView class. This object creates a tab control object CTabControl which is derived from CTabCtrl (I know some would say use property sheets but there is a reason for my madness and sets it up with two tabs. Everything is fine up to there.
    I also have two other CFormView objects (with their associated dialogs in the resouce) created using the wizard in MSVS .NET 2003. What I need to know is how to create these two windows using Dynamic Creation. I have never worked with Dynamic Creation in MFC and I would really appreciate a little snippet of code explaining how to do that. Thanks a lot,
    Amish

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,853
    sorry not sure what you mean....

    Have you tried adding the dialog as a class?
    highlight the entire dialog in the resource view, right click and 'add class'

    or add

    Code:
    // CSomeDlg.h dialog
    
    class CSomeDlg : public CDialog
    {
        DECLARE_DYNAMIC(CSomeDlg)
    
    // Dialog Data
    	enum	{ IDD = IDD_SOMEDLG };
    
    
    //*****************//
    // CSomeDlg.cpp dialog
    
    IMPLEMENT_DYNAMIC(CSomeDlg, CDialog)
    CSomeDlg::CSomeDlg(...........
    or are we talking about using Create() CreateWindow() ?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    205
    Yes I have already created a class for the dialogs but the classes are a subset of the CFormView class not a CDialog class since I want to use it in an SDI program. With CDialog, you can easily use Create but it seems from what I read online with CFormView, you have to "dynamically Create" them somehow in a different manner and I don't know how. Thanks for the answer though
    Amish

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,853
    more like this then....

    //allocate
    CSomeDlg *pThisDlg =new CSomeDlg;
    //create dialog
    pThisDlg->Create(....
    //use

    //free
    delete pThisDlg;
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Object Creation in thread function
    By sl4nted in forum Windows Programming
    Replies: 18
    Last Post: 10-11-2008, 02:37 PM
  2. Template object creation problem
    By babu198649 in forum C++ Programming
    Replies: 7
    Last Post: 09-16-2008, 04:02 AM
  3. Telling a shared_ptr not to delete object?
    By TriKri in forum C++ Programming
    Replies: 5
    Last Post: 08-16-2008, 04:26 AM
  4. Replies: 6
    Last Post: 10-30-2002, 08:03 PM
  5. dynamic object initialisation??
    By splendid bob in forum C++ Programming
    Replies: 2
    Last Post: 07-04-2002, 12:35 PM

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