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. Return value of a MFC Dialog Box Applicatin..

Return value of a MFC Dialog Box Applicatin..

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
11 Posts 5 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.
  • U User 3831761

    Hello, I want to have a custom return value of a dialog box application. We can change the return value by overriding ExitInstance(). Is it possible to have a string as return value? If yes how to achieve this? Thank you..

    C Offline
    C Offline
    Cedric Moonen
    wrote on last edited by
    #2

    The DoModal function returns an integer so you won't be able to change that (except if you create your own function to create the modla dialog). But anyway, this is in general not needed: you could simply add a function that returns you the string. The return of DoModal is used to return informatino about how the dialog has been closed to the user. It doesn't make a lot of sense to return some kind of data there.

    Cédric Moonen Software developer
    Charting control [v2.0] OpenGL game tutorial in C++

    1 Reply Last reply
    0
    • U User 3831761

      Hello, I want to have a custom return value of a dialog box application. We can change the return value by overriding ExitInstance(). Is it possible to have a string as return value? If yes how to achieve this? Thank you..

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #3

      Do you really want to return a string value to the OS? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      M 1 Reply Last reply
      0
      • C CPallini

        Do you really want to return a string value to the OS? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #4

        maybe it's called from another process ?

        This signature was proudly tested on animals.

        C 1 Reply Last reply
        0
        • M Maximilien

          maybe it's called from another process ?

          This signature was proudly tested on animals.

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #5

          Do you really want to return a string value to another process? ;P

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          M 1 Reply Last reply
          0
          • C CPallini

            Do you really want to return a string value to another process? ;P

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #6

            nope; but maybe the OP wants to.

            This signature was proudly tested on animals.

            C 1 Reply Last reply
            0
            • M Maximilien

              nope; but maybe the OP wants to.

              This signature was proudly tested on animals.

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #7

              Well, he should know then there are a lot of IPC mechanisms. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              U 1 Reply Last reply
              0
              • C CPallini

                Well, he should know then there are a lot of IPC mechanisms. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                U Offline
                U Offline
                User 3831761
                wrote on last edited by
                #8

                Requirement is to return a String? So have to find a soultion for it :( .. It is used by other process and that is already defined to take String as input..

                C W 2 Replies Last reply
                0
                • U User 3831761

                  Requirement is to return a String? So have to find a soultion for it :( .. It is used by other process and that is already defined to take String as input..

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #9

                  You may, for instance, return a integer value and then call the other process with a string appropriate to such a integer return value, e.g. (pseudocode):

                  int r = call(myProcess);
                  switch( r )
                  {
                  case eOK:
                  call(theOtherNastyProcess, "OK");
                  break;
                  ...
                  }

                  :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  1 Reply Last reply
                  0
                  • U User 3831761

                    Requirement is to return a String? So have to find a soultion for it :( .. It is used by other process and that is already defined to take String as input..

                    W Offline
                    W Offline
                    wmallory
                    wrote on last edited by
                    #10

                    Did you get your question fully answered by Cedric's response? I couldn't tell from your reply. If not, here's a little code snippet to demonstrate what (I believe) he was suggesting:

                    CMySpecialDialog MyDialog;

                    const int Status = MyDialog.DoModal();

                    if (Status == IDOK)
                    {
                    const CString MyString = MyDialog.GetMyString();
                    }

                    This will work if you define a GetMyString method in your CMySpecialDialog class. Just remember to keep the string value in a member variable of the CMySpecialDialog class so that it still exists after the return from DoModal. HTH

                    U 1 Reply Last reply
                    0
                    • W wmallory

                      Did you get your question fully answered by Cedric's response? I couldn't tell from your reply. If not, here's a little code snippet to demonstrate what (I believe) he was suggesting:

                      CMySpecialDialog MyDialog;

                      const int Status = MyDialog.DoModal();

                      if (Status == IDOK)
                      {
                      const CString MyString = MyDialog.GetMyString();
                      }

                      This will work if you define a GetMyString method in your CMySpecialDialog class. Just remember to keep the string value in a member variable of the CMySpecialDialog class so that it still exists after the return from DoModal. HTH

                      U Offline
                      U Offline
                      User 3831761
                      wrote on last edited by
                      #11

                      Thank you.. I will try on these lines..

                      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