[Gambas-user] Form enumeration

Benoit Minisini gambas at ...1...
Mon Mar 20 16:31:28 CET 2006


On Monday 20 March 2006 15:51, Christopher Brian Jack wrote:
> I'm having difficulty trying to write a sub that will close all open forms
> except the caller (it's intended that the caller be a Form most likely
> calling from his myform_Close handler and the all-but-the-caller is there
> to avoid endless loop condition)
>
> so in a module called "Common" I define the function
>
> from a Form's myform_Close handler he makes a call like this
>
> PUBLIC SUB myform_Close
>   Common.CloseAllForms(ME)
>   ME.Close()
> END
>
> In Common:
>
> PUBLIC SUB CloseAllForms(who as Object)
>   DIM which AS String
>   FOR EACH which IN ["Form1","Form2",...,"FormN"]
>     IF NOT (which=Object.Class(who)) THEN
>       'need to get object-from-string-in-which and use
>       'Object.Call(resultingObject,"Close")
>     END IF
>   NEXT
> END
>
> The trouble I'm running into is that it does not appear that there is a
> way to get back an object, given its string name.  I've tried the Class
> "array" --ie: Object.Call(Class(which),"Close")-- but it gives an error.
>
> I'm at a stumbling block here, any suggestions?
>
> .=================================================.
>
> |  Christopher BRIAN Jack aka "Gau of the Veldt"  |
>
> +================================================='
>
> | brian _AT_ brians-anime _DOT_ com
>
> `=================================================-
> Hi Spambots, my email address is sputnik at ...1334...
>

Enumerate the Windows class:

FOR EACH hWindow IN Windows
  ...
NEXT

Regards,

-- 
Benoit Minisini





More information about the User mailing list