Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to selfdestroy a class with references on forms

0 views
Skip to first unread message

Dieter Peters

unread,
Apr 11, 2000, 3:00:00 AM4/11/00
to
I have a "little" problem with references in a class.

The situation: A DLL project with one class and one form

The DLL has a public function ShowList e.g. it reads a file and displays a
result in a listview in a form.
I can't kill the form because I need it for later use. Sometimes I need more
than one list (form).
At this point I have to kill the class by a button_click in a form. The
problem is, that some
references of the forms (no controls) remain in the class. That means the
class never runs
through the Terminate and never frees the allocated memory (not the
complete).

So my question is if anybody solved problems like this?
Is my solution wrong, or do I need some mysterious api-functions?
What is the "right" way, if there is any?

Dieter

Zima

unread,
Apr 11, 2000, 3:00:00 AM4/11/00
to
Couple more things to clarify previous post (I didn't realize it might not
be obvious). In class constructor you want to setup m_frmWhatever to hold
the pointer to your form. You can do this like this:

Private Sub Class_Initialize()
Load MyForm
set m_frmWhatever = MyForm
End Sub

I'm assuming it's obvious m_frmWhatever is defined as private member at the
class scope like this:

Private m_frmWhatever As Form

Also, I'm assuming you've got your own implementations to display the form,
something like this:

Public Sub ShowMyForm()
m_frmWhatever.Show
End Sub

Finally, I had a little typo with the pointer assignment from class object
to client level var. Don't use parantheses to pass property as I had it.

' TYPO: Set frmDLLForm = oObj.FormList()

use it like this:

Set frmDLLForm = oObj.FormList

That should do it.
Bye now.

"Dieter Peters" <p...@rgu.de> wrote in message
news:e1TaxB7o$GA....@cppssbbsa02.microsoft.com...

Dieter Peters

unread,
Apr 12, 2000, 3:00:00 AM4/12/00
to

Zima <zimo...@NOSPAMexecpc.com> schrieb in im Newsbeitrag:
O2$QkL8o$GA.255@cppssbbsa04...

> Couple more things to clarify previous post (I didn't realize it might not
> be obvious). In class constructor you want to setup m_frmWhatever to hold
> the pointer to your form. You can do this like this:
>
> Private Sub Class_Initialize()
> Load MyForm
> set m_frmWhatever = MyForm
> End Sub
>
> I'm assuming it's obvious m_frmWhatever is defined as private member at
the
> class scope like this:
>
> Private m_frmWhatever As Form
>
> Also, I'm assuming you've got your own implementations to display the
form,
> something like this:
>
> Public Sub ShowMyForm()
> m_frmWhatever.Show
> End Sub
>
> Finally, I had a little typo with the pointer assignment from class object
> to client level var. Don't use parantheses to pass property as I had it.
>
> ' TYPO: Set frmDLLForm = oObj.FormList()
>
> use it like this:
>
> Set frmDLLForm = oObj.FormList
>
> That should do it.
> Bye now.

Ok, I see... but I forgot to show the whole problem (depends on my English).
Let me try to explain again:
I have a project (ActiveX-DLL), one form, one class.
Then I need to have several instances of e.g. Form1 (in Class1: set
oForm(Index) = Form1)
Then each instanced form needs a reference to Class1 (in Form1: Public
cParent = Class1) because they use subs and functions in Class1.
The problem occurs when closing (unload) the forms and leaving Class1. I
think the problem depends on crossreferencing form and class. And this is
the (a) real problem...


Dieter

0 new messages