[Gambas-user] R: How to know is my Form activated or not?

ML d4t4full at ...626...
Mon May 4 14:59:29 CEST 2015


Abbat,

I don't know if you got my reply to the list. I'd go like this instead
(this is code to add to the form(s) you want to check):

*  Private $bActive As Boolean = False**          'This private form
variable will hold the form's state
**  Public Property Read IsActive As Boolean     'This property will
return the private variable value**

**  Private Function IsActive_Read() As Boolean  'The function
declaration for reading the property**
**    Return ***$bActive *                           '  the current form
state is returned**
**  End**
**
  Public Sub Form_Activate()                   'This sub will change the
**private variable value to Active.
**    **$bActive**** = True**                           '  flag the
state as Active.
**  End**
**
  Public Sub Form_Deactivate()**                 'This sub will change
the **private variable value to Inactive.
**    **$bActive**= False**                           '  flag the state
as Inactive.**
**  End*

This works as follows: When you initially instance the form, the private
variable *$bActive* is set to FALSE.
When the form is activated, the *Form_Activate* event triggers and sets
the private variable *$bActive* as TRUE; when the form is deactivated,
the *Form_Deactivate* event triggers and sets the *$bActive* variable to
FALSE.
At any time, code external to the form can check the new form property
*IsActive* to find out if the form is active or not. This new property
will return the value TRUE or FALSE that has been set to the
*$bActive*** variable.

External code can check the new *IsActive* form property as follows:

*  Dim myForm As New frmWithProperty  'frmWithProperty is a form with
the above new property code included
  [... code ...]
**  If myForm.IsActive Then
    [... code for when the form is active...]
  Else
**    [... code for when the form is not active...]
  Endif
  [... even more code ...]*

The property can be added the same way to a single, some, or all forms
in the project.

Regards,
zxMarce.

*On 04/May/2015 09:24, abbat81 wrote:*
>   Dim dw As DesktopWindow   
>    For Each dw In Desktop.Windows   
>     Print "_" & dw.VisibleName
>    Next   
>
> I got next:
>
> _
> _
> _
> _
> _
> _
> _
> _
> _
> _
> _
> _
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list