THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/11/2008 at 03:25, xxxxxxxx wrote:
Hi! :)
Sure, I wanted to write, but I forgot in hectic. I wrote my own class like BaseLink, BaseBitmapLink.
> \> class DialogClassLink \> { \> private: \> void \*obj; \> public: \> DialogClassLink(); \> void \*Get(); \> void Set(void \*bmp); \> }; \> \> DialogClassLink::DialogClassLink() \> { \> obj = NULL; \> } \> \> void\* DialogClassLink::Get() \> { \> return obj; \> } \> \> void DialogClassLink::Set(void \*bmp) \> { \> obj = bmp; \> } \> \>
So this is my class which should return NULL if the dialog is not alive.
> \> \> class csDialogClass : public SubDialog \> { \> private: \> GeAutoDynamicArray<DialogClassLink\*>lnk; \> \> public: \> ~csDialogClass(); \> void PushClassLink(DialogClassLink\* obj); //this method is called if this dialog was passed to an object of DialogClassLink \> } \> \> void csDialogClass::PushClassLink(DialogClassLink\* obj) \> { \> lnk.Push(obj); \> } \> \> csDialogClass::~csDialogClass() \> { \> for(LONG i=0;i<lnk.count;i++) \> lnk[i]->Set(NULL); \> } \>
For example:
> \> csDialogClassLink\* my_diag = gNew csDialogClassLink; \> \> DialogClassLink \* lnk = gNew DialogClassLink; \> lnk->SetLink(my_diag); \> my_diag.PushClassLink(lnk); \> \> gDelete(my_diag); \> \> csDialogClassLink\* is_alive = (csDialogClassLink\* )lnk->Get(); //returns NULL because deconstructor sets 'lnk' member to NULL. \> \>
The dialog sets all members of DialogClassLinks to NULL which are connected to 'this'. I don't know if its the best way, but for me it works. If you hae any questions, critics or comments, please let me know.
Cheers, Seb.