Keeping the reference to a form
Posted on 2003-03-27
I've got an *.exe project that calls a dll. The first task is, from the exe, tell the dll (through its class) to show up a form (which in turn belongs to this dll). That's alright. But the thing is that when, from the exe, try to open a second form (without first closing the first form), this first form is still seen. How can I hide the first one with code?. I know it sounds easy enough, but take into account that when I click on the exe in order to show the second form, it goes through the class code and I lose the reference to the first one, so a "MyFirstForm.hide" wouldn't work because the dll now doesn't know who MyFirstForm is. A bit of code would clarify the problem ...
In my *.exe:
set Mydll as new DLL1.CLass1
Mydll.ShowForms(1) '1 would mean, show form 1, the 2nd call later on would be (2)
In my Class1:
Private WithEvents NewfrmMyFirstForm As MyFirstForm 'It has to be this way (WithEvents), both forms
Private WithEvents NewfrmMySecondForm As MySecondForm
public sub ShowForms(FormNumber as integer)
select case FormNumber
Set NewfrmMyFirstForm = New MyFirstForm
Set NewfrmMySecondForm = New MySecondForm
'After the second call from the exe, the old reference of NewfrmMyFirstForm is lost, so there is nothing to hide!!
Any ideas on how I can keep the old reference and hide the first form so?, any other way to do it?