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