[Solved] How to test if a form is open?

Creating and using forms

[Solved] How to test if a form is open?

Postby owlbrudder » Tue Feb 28, 2017 9:17 am

I have Googled this question and found plenty of code dating back to 2009 and thereabouts, but most of it does not work and the remainder does not answer my question.

I expected the application to be able to identify which forms are open, probably in an array, but I cannot find such an array anywhere in the object hierarchy. The Forms collection contains all the forms in the application whether they are open or not and I can't see anything the the properties of a Form that would tell me if it is open.

There must be a way, but I'm not finding it. Any help would be appreciated.

Kind regards,
Doug
Last edited by owlbrudder on Wed Mar 01, 2017 3:55 am, edited 1 time in total.
LibreOffice Version: 5.3.3.0
Fedora 26 Linux x86_64
Core i7, 8Gb
owlbrudder
 
Posts: 93
Joined: Tue Nov 08, 2016 8:04 am

Re: How to test if a form is open?

Postby Villeroy » Tue Feb 28, 2017 5:09 pm

A form won't be opened twice. When you double-click a form icon it will be loaded if required before its window comes up to the front. Why do you care?
In any case, the desktop object includes a collection of components. A form document is just an ordinary Writer document with an empty URL and a title like "MyDB.odb: Form1"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24374
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to test if a form is open?

Postby owlbrudder » Wed Mar 01, 2017 3:54 am

Villeroy wrote:Why do you care?

I am writing an application with potentially many forms and I don't want to clutter up the workspace with forms that have been in use but are no longer necessary to be open. Just being tidy, I suppose.

Anyway, you have answered my question fully as you always do - thank you.

Kind regards,
Doug
LibreOffice Version: 5.3.3.0
Fedora 26 Linux x86_64
Core i7, 8Gb
owlbrudder
 
Posts: 93
Joined: Tue Nov 08, 2016 8:04 am

Re: How to test if a form is open?

Postby owlbrudder » Wed Mar 01, 2017 4:21 am

owlbrudder wrote:I don't want to clutter up the workspace with forms

Doh! (Slaps forehead). I am closing each form when the user selects another activity, so I won't have lots of forms cluttering up the workspace. (Crawls back under rock muttering).

Anyway, it is interesting to know the Desktop object is where to look.
LibreOffice Version: 5.3.3.0
Fedora 26 Linux x86_64
Core i7, 8Gb
owlbrudder
 
Posts: 93
Joined: Tue Nov 08, 2016 8:04 am


Return to Forms

Who is online

Users browsing this forum: No registered users and 4 guests