B4J Question Is form already displayed?

cstangor

Member
Licensed User
Longtime User
I end up opening the same form twice with frm.show.

I'd like to know if it's already open so I don't.

Thanks in advance.
 

jmon

Well-Known Member
Licensed User
Longtime User
You could open the task manager and look for javaw.exe and how many times it's listed. if you opened it twice it would be there twice.
Actually with this method there is no way of knowing if this is that same program opened or another one. If you want to make sure you only run one instance of the program, you should compile your jar with Launch4J and check the "Allow only a single instance of the application" checkbox in the "single instance" tab.

I end up opening the same form twice with frm.show.
I'd like to know if it's already open so I don't.
.
It seems that it is actually not possible to show the MainForm.Show twice or more. Now if you actually built a class that displays another child form, then in your class you should contain a boolean variable that contains the "show" state of your window, a bit like this:

B4X:
Sub Class_Globals
    Private frm As Form
    Private isShown As Boolean = False
End Sub

Public Sub Show
    If Not(isShown) Then
        frm.Show
        isShown = True
    End If
End Sub

[edit] By the way, check my signature for "jAutoItX", there is a processList function that returns a list of the current processes.
 
Upvote 0
Top