Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Show information in the same dialog after press diferent button

Show information in the same dialog after press diferent button

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
25 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    antonio343
    wrote on last edited by
    #1

    Hi, I have an app (MDI,MFC) with some buttons. I want to show information in a dialogo box with Edit control when I press a button, and, in adittion, I want to show in the same dialog other text when I press other button. I know how to do the first part, but I dont know how to show other text in the same dialog when I press other button. Could you help me, plz? The buttons are in the Ribbon

    A S L 3 Replies Last reply
    0
    • A antonio343

      Hi, I have an app (MDI,MFC) with some buttons. I want to show information in a dialogo box with Edit control when I press a button, and, in adittion, I want to show in the same dialog other text when I press other button. I know how to do the first part, but I dont know how to show other text in the same dialog when I press other button. Could you help me, plz? The buttons are in the Ribbon

      A Offline
      A Offline
      Andre Kraak
      wrote on last edited by
      #2

      Please share any relevant code with us, seeing the code might us help understand the problem you are facing. Please specify where in the code you are having problem. If you wish to change your question use the Improve Question button.

      0100000101101110011001000111001011101001

      1 Reply Last reply
      0
      • A antonio343

        Hi, I have an app (MDI,MFC) with some buttons. I want to show information in a dialogo box with Edit control when I press a button, and, in adittion, I want to show in the same dialog other text when I press other button. I know how to do the first part, but I dont know how to show other text in the same dialog when I press other button. Could you help me, plz? The buttons are in the Ribbon

        S Offline
        S Offline
        Software_Developer
        wrote on last edited by
        #3

        If you want to change or replace all of the text n an edit control , use the CWnd::SetWindowText member function

        CString strText;
        GetDlgItem( IDC_EDIT1 )->SetWindowText( strText );

        CWnd::SetWindowText http://msdn.microsoft.com/en-us/library/yhczy8bz.aspx[^]

        L 1 Reply Last reply
        0
        • A antonio343

          Hi, I have an app (MDI,MFC) with some buttons. I want to show information in a dialogo box with Edit control when I press a button, and, in adittion, I want to show in the same dialog other text when I press other button. I know how to do the first part, but I dont know how to show other text in the same dialog when I press other button. Could you help me, plz? The buttons are in the Ribbon

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Your question is not very clear; however, if you mean by pressing an alternate button on the main window, then you will need a modeless dialog. If you mean a button in the dialog then your normal data exchange DDX_??? handlers should do it.

          Unrequited desire is character building. OriginalGriff

          A 1 Reply Last reply
          0
          • L Lost User

            Your question is not very clear; however, if you mean by pressing an alternate button on the main window, then you will need a modeless dialog. If you mean a button in the dialog then your normal data exchange DDX_??? handlers should do it.

            Unrequited desire is character building. OriginalGriff

            A Offline
            A Offline
            antonio343
            wrote on last edited by
            #5

            ok...when you press a button show a modeless dialog with a edit control to show text. Class view: void Cprueba4View::OnButton2() { CEjemplo *dlgDesc; dlgDesc = new CEjemplo(); dlgDesc->Create( IDD_DIALOG1 ,GetDesktopWindow()); dlgDesc->ShowWindow(1); } In class CEjemplo: void CEjemplo::ShowText(void) { CString cadena= _T("Hi, it is a example"); m_Edit.SetWindowTextW(cadena); } But I need, to show text from other class in the same dialog, that mean, the text, it will be added in the same windows when I press other button. Every button are in the ribbon.

            M L 2 Replies Last reply
            0
            • A antonio343

              ok...when you press a button show a modeless dialog with a edit control to show text. Class view: void Cprueba4View::OnButton2() { CEjemplo *dlgDesc; dlgDesc = new CEjemplo(); dlgDesc->Create( IDD_DIALOG1 ,GetDesktopWindow()); dlgDesc->ShowWindow(1); } In class CEjemplo: void CEjemplo::ShowText(void) { CString cadena= _T("Hi, it is a example"); m_Edit.SetWindowTextW(cadena); } But I need, to show text from other class in the same dialog, that mean, the text, it will be added in the same windows when I press other button. Every button are in the ribbon.

              M Offline
              M Offline
              Madhu Nair 0
              wrote on last edited by
              #6

              antonio343 wrote:

              I need, to show text from other class in the same dialog

              How about making the ShowText function as public and pass a CString variable ;

              void CEjemplo::ShowText(CString strText)
              {
              //CString cadena= _T("Hi, it is a example");
              m_Edit.SetWindowTextW(strText);
              //Add this to invoke DDX updation
              UpdateData(FALSE);
              }

              call the public function of CEjemplo object as,

              void CSomeOtherClass::ShowText()
              {
              CEjemplo oEjemplo;
              CSting strText(_T("Some text from other class"));
              oEjemplo.ShowText(strText);
              }

              A 1 Reply Last reply
              0
              • M Madhu Nair 0

                antonio343 wrote:

                I need, to show text from other class in the same dialog

                How about making the ShowText function as public and pass a CString variable ;

                void CEjemplo::ShowText(CString strText)
                {
                //CString cadena= _T("Hi, it is a example");
                m_Edit.SetWindowTextW(strText);
                //Add this to invoke DDX updation
                UpdateData(FALSE);
                }

                call the public function of CEjemplo object as,

                void CSomeOtherClass::ShowText()
                {
                CEjemplo oEjemplo;
                CSting strText(_T("Some text from other class"));
                oEjemplo.ShowText(strText);
                }

                A Offline
                A Offline
                antonio343
                wrote on last edited by
                #7

                ok, but.. Where I define strText? And.. to show the text I need the method OnInitDialog in class CEjemplo, but if I add the parameter I need to pass the paramenter to this method and it isn't possible.

                BOOL CEjemplo::OnInitDialog()
                {
                CDialogEx::OnInitDialog();
                ShowText();
                // TODO: Agregue aquí la inicialización adicional

                return TRUE;  // return TRUE unless you set the focus to a control
                // EXCEPCIÓN: las páginas de propiedades OCX deben devolver FALSE
                

                }

                1 Reply Last reply
                0
                • S Software_Developer

                  If you want to change or replace all of the text n an edit control , use the CWnd::SetWindowText member function

                  CString strText;
                  GetDlgItem( IDC_EDIT1 )->SetWindowText( strText );

                  CWnd::SetWindowText http://msdn.microsoft.com/en-us/library/yhczy8bz.aspx[^]

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  What is wrong with this[^]?

                  Unrequited desire is character building. OriginalGriff

                  S 1 Reply Last reply
                  0
                  • A antonio343

                    ok...when you press a button show a modeless dialog with a edit control to show text. Class view: void Cprueba4View::OnButton2() { CEjemplo *dlgDesc; dlgDesc = new CEjemplo(); dlgDesc->Create( IDD_DIALOG1 ,GetDesktopWindow()); dlgDesc->ShowWindow(1); } In class CEjemplo: void CEjemplo::ShowText(void) { CString cadena= _T("Hi, it is a example"); m_Edit.SetWindowTextW(cadena); } But I need, to show text from other class in the same dialog, that mean, the text, it will be added in the same windows when I press other button. Every button are in the ribbon.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    So add a function to your dialog that manages the text, then you can call that function as different buttons are pressed. However, I would say that your design is not the best way of doing things in Windows.

                    Unrequited desire is character building. OriginalGriff

                    A 1 Reply Last reply
                    0
                    • L Lost User

                      So add a function to your dialog that manages the text, then you can call that function as different buttons are pressed. However, I would say that your design is not the best way of doing things in Windows.

                      Unrequited desire is character building. OriginalGriff

                      A Offline
                      A Offline
                      antonio343
                      wrote on last edited by
                      #10

                      I didnt understand you. If you know a better way to do, let me know, please.

                      L 1 Reply Last reply
                      0
                      • L Lost User

                        What is wrong with this[^]?

                        Unrequited desire is character building. OriginalGriff

                        S Offline
                        S Offline
                        Software_Developer
                        wrote on last edited by
                        #11

                        doooh : :doh: yes, yes indeed.. SetDlgItemText(Dialogbox, IDC_EDITBOX, sString);

                        1 Reply Last reply
                        0
                        • A antonio343

                          I didnt understand you. If you know a better way to do, let me know, please.

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #12

                          As I understand it you are changing the content of the dialog by pressing a button on the main form. This will not be a good experience for your users, as most people like to interact with one window at a time. For example: If the user presses a button on the main form and a dialog appears, all user action should now be with that dialog until the dialog is dismissed. If they have to go back to the main form to press a button to change something in the dialog then things get confused. If my understanding of your system is incorrect I apologise for my confusion.

                          Unrequited desire is character building. OriginalGriff

                          A 1 Reply Last reply
                          0
                          • L Lost User

                            As I understand it you are changing the content of the dialog by pressing a button on the main form. This will not be a good experience for your users, as most people like to interact with one window at a time. For example: If the user presses a button on the main form and a dialog appears, all user action should now be with that dialog until the dialog is dismissed. If they have to go back to the main form to press a button to change something in the dialog then things get confused. If my understanding of your system is incorrect I apologise for my confusion.

                            Unrequited desire is character building. OriginalGriff

                            A Offline
                            A Offline
                            antonio343
                            wrote on last edited by
                            #13

                            The idea is it dialog is used to show dates. The app will be a estadistic program, like SPSS, you will have a several variables and if you choose one of this and press a one button, in the dialog will be show the average, and if you after press other button, it will be added to the dialog the frecuency, for example. Due to it, I'd like to get show diferent information from diferent class in the same dialog. Please, help me.

                            L 1 Reply Last reply
                            0
                            • A antonio343

                              The idea is it dialog is used to show dates. The app will be a estadistic program, like SPSS, you will have a several variables and if you choose one of this and press a one button, in the dialog will be show the average, and if you after press other button, it will be added to the dialog the frecuency, for example. Due to it, I'd like to get show diferent information from diferent class in the same dialog. Please, help me.

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #14

                              Your original message states that this is an MDI application, so it would seem the obvious answer is to show your results in one of the MDI windows. Alternatively put all your selector buttons into the dialog and just use the button handlers to get the data from wherever it is held and display it in the dialog.

                              Unrequited desire is character building. OriginalGriff

                              A 1 Reply Last reply
                              0
                              • L Lost User

                                Your original message states that this is an MDI application, so it would seem the obvious answer is to show your results in one of the MDI windows. Alternatively put all your selector buttons into the dialog and just use the button handlers to get the data from wherever it is held and display it in the dialog.

                                Unrequited desire is character building. OriginalGriff

                                A Offline
                                A Offline
                                antonio343
                                wrote on last edited by
                                #15

                                No, I cant. This windows/dialog is only to show the result. Now, I show each result in one dialog diferent, but I'd like to group all the result in one dialog, and after, I will make a button in this dialog to save the information in a txt for example. But I must to do at this way

                                L D 2 Replies Last reply
                                0
                                • A antonio343

                                  No, I cant. This windows/dialog is only to show the result. Now, I show each result in one dialog diferent, but I'd like to group all the result in one dialog, and after, I will make a button in this dialog to save the information in a txt for example. But I must to do at this way

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #16

                                  antonio343 wrote:

                                  No, I cant.

                                  I have offered two suggestion which would make life easier for you, I cannot think of a third that would be better.

                                  Unrequited desire is character building. OriginalGriff

                                  1 Reply Last reply
                                  0
                                  • A antonio343

                                    No, I cant. This windows/dialog is only to show the result. Now, I show each result in one dialog diferent, but I'd like to group all the result in one dialog, and after, I will make a button in this dialog to save the information in a txt for example. But I must to do at this way

                                    D Offline
                                    D Offline
                                    David Crow
                                    wrote on last edited by
                                    #17

                                    You never clarified whether you were using a modal or modeless dialog. I don't think your issue can be addressed until that is made clear.

                                    "One man's wage rise is another man's price increase." - Harold Wilson

                                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                    "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                                    A 1 Reply Last reply
                                    0
                                    • D David Crow

                                      You never clarified whether you were using a modal or modeless dialog. I don't think your issue can be addressed until that is made clear.

                                      "One man's wage rise is another man's price increase." - Harold Wilson

                                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                      "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                                      A Offline
                                      A Offline
                                      antonio343
                                      wrote on last edited by
                                      #18

                                      I'm sorry, you are right. It is a modeless dialog. I'm triying use set and get DlgItemText, but maybe I dont know how to use it. I made this:

                                      void Cprueba4View::OnButton3()
                                      {

                                      CString cadena;
                                      GetDlgItemText(IDC\_EDIT1, cadena);
                                      cadena += "Helloo other time ";
                                      SetDlgItemText(IDC\_EDIT1, cadena);
                                      

                                      }

                                      D A 2 Replies Last reply
                                      0
                                      • A antonio343

                                        I'm sorry, you are right. It is a modeless dialog. I'm triying use set and get DlgItemText, but maybe I dont know how to use it. I made this:

                                        void Cprueba4View::OnButton3()
                                        {

                                        CString cadena;
                                        GetDlgItemText(IDC\_EDIT1, cadena);
                                        cadena += "Helloo other time ";
                                        SetDlgItemText(IDC\_EDIT1, cadena);
                                        

                                        }

                                        D Offline
                                        D Offline
                                        David Crow
                                        wrote on last edited by
                                        #19

                                        Do not interact with UI controls from any place other than the owning window (the modeless dialog in this case). If you need the modeless dialog to update its controls, send it a message.

                                        "One man's wage rise is another man's price increase." - Harold Wilson

                                        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                                        1 Reply Last reply
                                        0
                                        • A antonio343

                                          I'm sorry, you are right. It is a modeless dialog. I'm triying use set and get DlgItemText, but maybe I dont know how to use it. I made this:

                                          void Cprueba4View::OnButton3()
                                          {

                                          CString cadena;
                                          GetDlgItemText(IDC\_EDIT1, cadena);
                                          cadena += "Helloo other time ";
                                          SetDlgItemText(IDC\_EDIT1, cadena);
                                          

                                          }

                                          A Offline
                                          A Offline
                                          antonio343
                                          wrote on last edited by
                                          #20

                                          Ok, finally, I got my answer. I solved of this way: I made a public variable of my dialog class, where is the edit control, in the class view, and I made the windows in the builder. After, when I press a button, I did :

                                          void Cprueba4View::OnButton3()
                                          {

                                          CString cadena;
                                          dlgDesc->GetDlgItemText(IDC\_EDIT1, cadena);
                                          cadena += "Hello other time ";
                                          dlgDesc->SetDlgItemText(IDC\_EDIT1, cadena);
                                          dlgDesc->SetFocus();
                                          

                                          }

                                          But now, I have another problem. When I maximize the windows dialog, only it's maximized the windows and not the edit control. why? how can I maximize the windows and the edit control at the same time? I used

                                          dlgDesc->ShowWindow(SW\_MAXIMIZE);
                                          

                                          to maximized

                                          D 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups