Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why modaless dialog box on the heap?

Status
Not open for further replies.

Dennis7

Programmer
Dec 10, 2001
6
0
0
IN
Can anybody tell mw why the modaless dialog box is created on the heap and why modal dialog box is created on the stack..

Is there any logical answer behind this...
Waiting for ur reply.....

With Regards
Dinesh
 
In general you create a modeless dialogue in a function, and then return to do other processing, when you close the dialogue box it usually frees up the memory allocated on the heap itself.
If the dialogue box memory was on the stack, then it would be lost when you returned form the function.
Allocation on the stack is efficient, and if the thread creating the box waits for the box to be closed before proceeding, there is no real reason to complicate life by creating the box on the heap, and then remembering to delete the box when you have completed.
 
Modaless dialog box can't be created on the stack...because u have to call a Create fucntion for this type of dialog box...What i think the secret lies in the heap ..heap is the extra memory which is being used by the programm(or application) and there is a separate thread to manage the heap and that's why u can do other while while the modaless dialog box is visible....where as the stack objects are managed by the same thread of the application and hence
the control gets trapped there....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top