I know of FONT.
I am not sure about brush and pen.
Are there others?
Thanks in advance
Otto
I know of FONT.
I am not sure about brush and pen.
Are there others?
Thanks in advance
Otto
Generally speaking, any resources that you explicitly create you have to explicitly release.
EMG
Otto,
It is a good idea to call the End() method of every object you create; even if it is not actually needed. This way you don't have to remember which ones need it and which don't.
This is also why I suggest including an End() method in any class you create.
James
James,
You don't need to explicitly End() TGets, TComboBoxes, TDialogs, etc.
EMG
You don't need to explicitly End() TGets, TComboBoxes, TDialogs, etc.
James Bott wrote:Controls like gets and comboboxes, no, but I always end dialogs. How else do you close them?
James Bott wrote:I was just saying that if you are not sure if you need to call End() then it is better to just do it and then you don't have to worry about resource leaks, files left open, etc.
If you review Class TWindow Method Destroy() you will see that all the resources used by a window are automatically End()ed.
This applies to dialogs and controls too as they both inherit from Class TWindow
Generally is the user that closes the dialog.
I don't think this is a correct approach. It's always better to know what's going on.
It's even possible (but I'm not sure) that double release can cause some kind of problems.
Please review Class TWindow Method Destroy() source code ![]()
Any other GDI object that is not listed there as a DATA, has to be End()ed manually, as Enrico has pointed.
Anyhow, Windows automatically will take care of those GDI objects even if we don't explicity release them, when the app finsihes.
The problem only comes when a GDI object is created again and again from the application, so the the GDI memory is wasted and Windows won't act as it doesn't know if they are still needed or not.
James Bott wrote:Ah, I guess you mean using the close button on the title bar. I remove those, so the user has to use the buttons on the dialog and the OK or Close button has to call oDlg:end().
James Bott wrote:I guess we would need a complete list of which classes need to be ended by the programmer and which don't.
Antonio Linares wrote:Anyhow, Windows automatically will take care of those GDI objects even if we don't explicity release them, when the app finsihes.
Anyhow, Windows automatically will take care of those GDI objects even if we don't explicity release them, when the app finsihes.
Antonio Linares wrote:Enrico,
http://msdn.microsoft.com/en-us/library/ms724291(VS.85).aspx
"Handles to GDI objects are private to a process."
So when the process is finished, all its environment is cleared, unless you have created global handles (i.e. using GlobalAlloc()).
GDI objects support only one handle per object. Handles to GDI objects are private to a process. That is, only the process that created the GDI object can use the object handle.
Antonio Linares wrote:http://msdn.microsoft.com/en-us/magazine/cc301756.aspx
"... the documentation states that Windows takes care of releasing the resource used by a process when it exits ..."
Even if the documentation states that Windows takes care of releasing the resource used by a process when it exits, this is not enough for server applications that must be extremely reliable.
Enrico,
There are only two ways to manage the memory: locally and globally.
Global memory is shared by the entire operating system. Local memory is allocated from the heap of a process. The heap is local to a process and when the process is released, its heap is also cleared.
This is common to all operating systems.
Anyhow if you want to read the exact words from Microsoft, then lets keep googling for it ![]()