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. MFC Dialog application

MFC Dialog application

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
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.
  • B Offline
    B Offline
    bhanu_8509
    wrote on last edited by
    #1

    Dear All, Is there any way to create global objects to all the classes in the MFC dialog based application ? I want to use the object of one class from the other class, but I want to create the object only once. The object created for each class should be a singleton object. Please help me. Thanks in advance.

    CPalliniC R L 3 Replies Last reply
    0
    • B bhanu_8509

      Dear All, Is there any way to create global objects to all the classes in the MFC dialog based application ? I want to use the object of one class from the other class, but I want to create the object only once. The object created for each class should be a singleton object. Please help me. Thanks in advance.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      And what is your trouble about? You may use static members or (as you already are aware) the singleton design pattern. BTW: the (in)famous theApp object is a (wizard created) sample of a global MFC object. :)

      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]

      In testa che avete, signor di Ceprano?

      B 1 Reply Last reply
      0
      • B bhanu_8509

        Dear All, Is there any way to create global objects to all the classes in the MFC dialog based application ? I want to use the object of one class from the other class, but I want to create the object only once. The object created for each class should be a singleton object. Please help me. Thanks in advance.

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #3

        Hi Bhanu, It's not clear from your question as to what exactly do you want. May be you tell what exactly is your problem and I'm sure people over here will be suggest you the best way to go about solving it.

        It is a crappy thing, but it's life -^ Carlo Pallini

        CPalliniC 1 Reply Last reply
        0
        • B bhanu_8509

          Dear All, Is there any way to create global objects to all the classes in the MFC dialog based application ? I want to use the object of one class from the other class, but I want to create the object only once. The object created for each class should be a singleton object. Please help me. Thanks in advance.

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          bhanu_8509 wrote:

          Is there any way to create global objects

          Yes

          bhanu_8509 wrote:

          The object created for each class should be a singleton object.

          Yes, that is a way to create a global object. However the Singleton pattern is well known to be overused/abused. Prefer other patterns such as MVC and Factory creational patterns.

          led mike

          N 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            Hi Bhanu, It's not clear from your question as to what exactly do you want. May be you tell what exactly is your problem and I'm sure people over here will be suggest you the best way to go about solving it.

            It is a crappy thing, but it's life -^ Carlo Pallini

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

            Rajesh R Subramanian wrote:

            I'm sure people over here

            So true: did you notice today we have the 'bestest' [^]? :-D

            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]

            In testa che avete, signor di Ceprano?

            R 1 Reply Last reply
            0
            • L led mike

              bhanu_8509 wrote:

              Is there any way to create global objects

              Yes

              bhanu_8509 wrote:

              The object created for each class should be a singleton object.

              Yes, that is a way to create a global object. However the Singleton pattern is well known to be overused/abused. Prefer other patterns such as MVC and Factory creational patterns.

              led mike

              N Offline
              N Offline
              Nemanja Trifunovic
              wrote on last edited by
              #6

              led mike wrote:

              Prefer other patterns such as MVC and Factory creational patterns.

              Even better, prefer KISS pattern[^] and avoid design patterns altogether.

              Programming Blog utf8-cpp

              CPalliniC 1 Reply Last reply
              0
              • N Nemanja Trifunovic

                led mike wrote:

                Prefer other patterns such as MVC and Factory creational patterns.

                Even better, prefer KISS pattern[^] and avoid design patterns altogether.

                Programming Blog utf8-cpp

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

                Surely you're joking Mr.Feynman Trifunovic! :-D

                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]

                In testa che avete, signor di Ceprano?

                1 Reply Last reply
                0
                • CPalliniC CPallini

                  And what is your trouble about? You may use static members or (as you already are aware) the singleton design pattern. BTW: the (in)famous theApp object is a (wizard created) sample of a global MFC object. :)

                  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]

                  B Offline
                  B Offline
                  bhanu_8509
                  wrote on last edited by
                  #8

                  My exact problem is that, I am using four dialog in my MFC application. I want to open the a dialog from another dialog. I am using OnCancel() for closing the current dialog and use DoModal() to open the other dialog. If I do like this for more no. of times then I got assertion and I found that this happens due to memory overflow due to the recursive call of DoModal(). I want to create global (single) objects for all classes and using those objects I need to hide the window and show the window instead of using OnCancel and DoModal. But I am not so experienced in defining global objects and static objects. Please help me with some samples. P.S : I dont want to use Property sheet or Tabbed dialogs or MDI. Thanks in advance

                  CPalliniC 1 Reply Last reply
                  0
                  • B bhanu_8509

                    My exact problem is that, I am using four dialog in my MFC application. I want to open the a dialog from another dialog. I am using OnCancel() for closing the current dialog and use DoModal() to open the other dialog. If I do like this for more no. of times then I got assertion and I found that this happens due to memory overflow due to the recursive call of DoModal(). I want to create global (single) objects for all classes and using those objects I need to hide the window and show the window instead of using OnCancel and DoModal. But I am not so experienced in defining global objects and static objects. Please help me with some samples. P.S : I dont want to use Property sheet or Tabbed dialogs or MDI. Thanks in advance

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

                    bhanu_8509 wrote:

                    I want to open the a dialog from another dialog.

                    This may be easily done using modal dialog boxes (i. e. DoModal()), all that you need is the proper communication of each dialog with the common parent window (see this nice toxcct's article about [^]). :)

                    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]

                    In testa che avete, signor di Ceprano?

                    1 Reply Last reply
                    0
                    • CPalliniC CPallini

                      Rajesh R Subramanian wrote:

                      I'm sure people over here

                      So true: did you notice today we have the 'bestest' [^]? :-D

                      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]

                      R Offline
                      R Offline
                      Rajesh R Subramanian
                      wrote on last edited by
                      #10

                      :laugh: Thanks for the funniestest link. :)

                      It is a crappy thing, but it's life -^ Carlo Pallini

                      CPalliniC 1 Reply Last reply
                      0
                      • R Rajesh R Subramanian

                        :laugh: Thanks for the funniestest link. :)

                        It is a crappy thing, but it's life -^ Carlo Pallini

                        CPalliniC Offline
                        CPalliniC Offline
                        CPallini
                        wrote on last edited by
                        #11

                        Iain is indeed fantastic! (or 'The fantastestic' ?!?!) :)

                        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]

                        In testa che avete, signor di Ceprano?

                        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