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. wher should be a modeless dialog box be created

wher should be a modeless dialog box be created

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
6 Posts 3 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.
  • S Offline
    S Offline
    Sujay chakraborty
    wrote on last edited by
    #1

    Hello all, I came across a question regarding modeless dialog box and i am confused regarding the answer. The question goes like this A Modeless dialog box must not be created over 1) Heap 2) Stack 3) Globally 4) Locally Static which is the appropriate option to choose. Will locally static have the same scope as that of globally declared objects. As its clear that for a modeless dialog box the object must be accessible throughout the program Regards Sujay

    _ 1 Reply Last reply
    0
    • S Sujay chakraborty

      Hello all, I came across a question regarding modeless dialog box and i am confused regarding the answer. The question goes like this A Modeless dialog box must not be created over 1) Heap 2) Stack 3) Globally 4) Locally Static which is the appropriate option to choose. Will locally static have the same scope as that of globally declared objects. As its clear that for a modeless dialog box the object must be accessible throughout the program Regards Sujay

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      It is really a question of scope of the dialog variable. So it all depends on from where all you really want to access the variable. And unlike a modal dialog, the calling thread is not blocked when a modeless dialog is created and shown.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      S 1 Reply Last reply
      0
      • _ _Superman_

        It is really a question of scope of the dialog variable. So it all depends on from where all you really want to access the variable. And unlike a modal dialog, the calling thread is not blocked when a modeless dialog is created and shown.

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        S Offline
        S Offline
        Sujay chakraborty
        wrote on last edited by
        #3

        actually which answer will be more precise....i mean if u compulsory need to choose one out of four. frankly i am confused between static local and stack....... got to be one of these two........

        T 1 Reply Last reply
        0
        • S Sujay chakraborty

          actually which answer will be more precise....i mean if u compulsory need to choose one out of four. frankly i am confused between static local and stack....... got to be one of these two........

          T Offline
          T Offline
          Tim Craig
          wrote on last edited by
          #4

          In a modal dialog your main program is halted (assuming your application is single threaded) while you enter data into the dialog. When you finish with the modal dialog, your main program accesses the data you entered and then processes it. You use a modeless dialog when you need to continuously interact with your application through the dialog. You enter some data and your application can act on that input immediately without dismissing the dialog. Conversley, you might continuously display data in a modeless dialog that your application can keep updating as processing proceeds. The choice of which to use is how long the dialog must be up and how the data flows between the dialog and the application.

          You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

          S 1 Reply Last reply
          0
          • T Tim Craig

            In a modal dialog your main program is halted (assuming your application is single threaded) while you enter data into the dialog. When you finish with the modal dialog, your main program accesses the data you entered and then processes it. You use a modeless dialog when you need to continuously interact with your application through the dialog. You enter some data and your application can act on that input immediately without dismissing the dialog. Conversley, you might continuously display data in a modeless dialog that your application can keep updating as processing proceeds. The choice of which to use is how long the dialog must be up and how the data flows between the dialog and the application.

            You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

            S Offline
            S Offline
            Sujay chakraborty
            wrote on last edited by
            #5

            Hello Tim, Thanks for the answer, but the question here is about the creation of Modeless dialog box. What i have understand from my reading is that, for modeless dialog box we need to create its object so that its scope is maintained throughout the application, in case u need it that way....... So to achieve that whether it be good to create that object in Heap, Stack, Global, or locally static.??? One more thing, is it true that the scope of a variable declared 'Locally Static' is same as that declared 'Globally'??? Regards Sujay

            T 1 Reply Last reply
            0
            • S Sujay chakraborty

              Hello Tim, Thanks for the answer, but the question here is about the creation of Modeless dialog box. What i have understand from my reading is that, for modeless dialog box we need to create its object so that its scope is maintained throughout the application, in case u need it that way....... So to achieve that whether it be good to create that object in Heap, Stack, Global, or locally static.??? One more thing, is it true that the scope of a variable declared 'Locally Static' is same as that declared 'Globally'??? Regards Sujay

              T Offline
              T Offline
              Tim Craig
              wrote on last edited by
              #6

              The lifetime of the modeless dialog only has to be the duration that you want it directly available to the user. Some people do this by keeping it available the lifetime of the application and hide it when it's not needed. Others create it on the heap when the user wants it and then destroy it when the user is done. If you have several of them, it goes a little lighter on your resources. If you put it on the stack, you need to be very careful about how it's scoped. This limits where it can be done in your typical application as it will be destroyed if it goes out of scope. Scope is about visibility, if it's "locally" static, that kind of implies its visibility is limited. Either to a particular file or even a single function. If you mean a class static, that has a slightly different meaning. The storage exists for the life of the program and scoping is controlled by the class name. Of course, you can make static data available outside their primary scope in various ways.

              You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

              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