Help needed to create forms
Posted
#1
(In Topic #371)
Regular

With hForm = New Form
.Name = "xx"
.X = 50
.Y = 50
.W = 200
.H = 200
.Caption = "new"
.Show
End With
This code will create a number of new forms but they still exist after the project is closed, how can I close them when the project is closed?
Any help appreciated
Posted
Regular

bill-lancaster said
…This code will create a number of new forms but they still exist after the project is closed…
You basically need to reference each form in the main form's close event:-
But exactly how you do this may depend upon how you are creating the additional forms (i.e. whether you can simply do this using known form names, or whether you need a more flexible approach).
Posted
Regular

You're right, referencing the forms is the question.
If a form call hForm is created (as per my example) then it can be destroyed with 'hForm.Close', but the code can create multiple forms and 'hForm.Close' closes only the first one created since the others won't have the same name.
I imaging the 'handle' property might be useful here but how?
Posted
Regular

It work though!
Posted
Guru

The help is here.
Code (gambas)
- .Name = "xx"
- .X = siCount * 50
- .Y = siCount * 50
- .W = 200
- .H = 200
- .Show
Posted
Regular

Any ideas?
Posted
Regular

Posted
Guru

Thank you cogier, that works nicely, however, I realise that I have a main form from which is opened a second form (Form2). New windows generated from Form2 don't close with hForm.Close. Have tried Application.MainWindow = Me and Application.MainWindow = fMain but the new forms don't close.
Any ideas?
Can you provide some code as to how you are doing this please, that is if Steve's answer isn't the solution. (Which it probably is as he's good :!: )
Posted
Regular

If cwin.Name = "FDocShow" Then cwin.Close
does the job
Thanks again
1 guest and 0 members have just viewed this.


