Question under MFC...

This is a discussion on Question under MFC... within the C++ Programming forums, part of the General Programming Boards category; Hey... Ive been making a Program with Microsoft Visual C++ 6.0... Ive made it so that my Main interface window ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    7

    Question under MFC...

    Hey...

    Ive been making a Program with Microsoft Visual C++ 6.0...

    Ive made it so that my Main interface window has buttons, and ive made other CDialog resources but I dont know how to make it so when i click on the Button on the main interface itll open another CDialog window...

    How would i do that?

    Code:
    void CClientDlg::OnButton01() 
    { 
        /*How do i Link it to Button01.cpp or IDD_Dialog1?*/ 
    }

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Code:
    void CClientDlg::OnButton01() 
    { 
        CMyOtherDlg Dlg;
        if(Dlg.DoModal() == IDOK)
        {
              //Handle whatever
        }
    }

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    7
    Code:
    void CClientDlg::OnButton01() 
    { 
          /* CClientDlg (ID: IDD_CLIENT_DIALOG) 
                                  (CPP: ClientDlg.cpp) 
              Button01 (ID: IDD_DIALOG1) 
                            (CPP: Button01.cpp) */ 
    
        /* CMyOtherDlg Dlg;
        if(Dlg.DoModal() == IDOK)
        {
              //Handle whatever
        } */
    
        IDD_DIALOG1 Dlg;
        if(Dlg.DoModal() == IDOK)
        {
              //Handle whatever
        }
    }
    3 Errors, 0 Warnings...

    C:\*\ClientDlg.cpp(179) : error C2146: syntax error : missing ';' before identifier 'Dlg'
    C:\*\ClientDlg.cpp(179) : error C2065: 'Dlg' : undeclared identifier
    C:\*\ClientDlg.cpp(180) : error C2228: left of '.DoModal' must have class/struct/union type

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    It cant be a resource ID, it needs to be a full MFC class derived from CDialog.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    7
    Thanks i fixed the problem...

    Code:
    #include "Button01Dlg.h"
    
    void CClientDlg::OnButton01() 
    {
       CButton01Dlg dlg;
       dlg.DoModal();
    }
    But Ive come to Notice that only Text can be added to the CButton01Dlg on interface... I was wondering if there was a way to somehow get printf or cout working in Button01Dlg.cpp in order to apply variables?...

  6. #6
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Just pointing out that: this is a C++ forum, and although your questions are about C++, the questions you are asking are related to what's called "windows programming". On this site, there is actually a "windows programming" forum for such questions that you might want to consider next time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MFC check box question
    By MyglyMP2 in forum Windows Programming
    Replies: 2
    Last Post: 03-09-2009, 06:47 PM
  2. MFC simple question
    By dole.doug in forum Windows Programming
    Replies: 5
    Last Post: 09-26-2008, 07:11 AM
  3. Window Resize question (MFC)
    By IfYouSaySo in forum Windows Programming
    Replies: 2
    Last Post: 11-16-2005, 12:34 PM
  4. MFC UI question
    By naruto in forum Windows Programming
    Replies: 1
    Last Post: 04-21-2005, 11:10 PM
  5. MFC Dialog App Screen Refresh Question
    By Scotth10 in forum Windows Programming
    Replies: 2
    Last Post: 10-18-2002, 03:07 PM

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