Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help with forms

ibouxiboux Posts: 1Member
I'm new to MFC and I created a SDI application. Now I added a new form and the based class is CFromView. Everytime I compile the project, I get a little pop-up window which is asking me to choose which form to load. How can I set one of the form as a default and I would like to add a button on the main to call the second form. Like we do in VB.
Thanks...

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    : I'm new to MFC and I created a SDI application. Now I added a new form and the based class is CFromView. Everytime I compile the project, I get a little pop-up window which is asking me to choose which form to load. How can I set one of the form as a default and I would like to add a button on the main to call the second form. Like we do in VB.
    : Thanks...
    :


    [blue] In your program's CWinApp-derived class's InitInstance, delete the lines shown below in [red]RED[/red] for the extra forms that you created. From now on, to prevent this from occuring again, first create a dialog box, then select Class Wizzard and it will ask you for the name of the class. From that dialog you reassign the base class from CDialog to CFormView. Also make sure to set the dialog's Style to Child and Border to None in the dialog's Properties.[/blue]

    [code]
    BOOL CTest1App::InitInstance()
    {
    [red]
    { // BLOCK: doc template registration
    // Register the document template. Document templates serve
    // as the connection between documents, frame windows and views.
    // Attach this form to another document or frame window by changing
    // the document or frame class in the constructor below.
    CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate(
    IDR_MYFORM_TMPL,
    RUNTIME_CLASS(CTest1Doc), // document class
    RUNTIME_CLASS(CMainFrame), // frame class
    RUNTIME_CLASS(CMyForm)); // view class
    AddDocTemplate(pNewDocTemplate);
    }
    [/red]
    AfxEnableControlContainer();

    // Standard initialization
    // If you are not using these features and wish to reduce the size
    // of your final executable, you should remove from the following
    // the specific initialization routines you do not need.

    #ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endif

    // Change the registry key under which our settings are stored.
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization.
    SetRegistryKey(_T("Local AppWizard-Generated Applications"));

    LoadStdProfileSettings(); // Load standard INI file options (including MRU)

    // Register the application's document templates. Document templates
    // serve as the connection between documents, frame windows and views.

    CSingleDocTemplate* pDocTemplate;
    pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CTest1Doc),
    RUNTIME_CLASS(CMainFrame), // main SDI frame window
    RUNTIME_CLASS(CTest1View));
    AddDocTemplate(pDocTemplate);

    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);

    // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    return FALSE;

    // The one and only window has been initialized, so show and update it.
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();

    return TRUE;
    }

    [/code]

Sign In or Register to comment.