[Gambas-user] new user

Stephen Bungay sbungay at ...981...
Tue Sep 2 15:52:21 CEST 2008


   Yet another way of doing this is to use public properties. For 
example, a small form class that pops up a message might look like this;

PRIVATE mMessageText AS String

PUBLIC PROPERTY MessageText AS String

PRIVATE FUNCTION MessageText_Read() AS String
     RETURN (mMessageText)
END

PRIVATE SUB MessageText_Write(Value AS String)
   mMessageText = Value
   TextArea1.Text = Value
   Timer2.Enabled = TRUE
END

PUBLIC SUB Timer2_Timer()
    ME.Close
END


   You set the value of properties and the class does whatever it was 
designed to do with them, in this case set  a TextArea to the value that 
was set in the public property "MessageText". The form has a timer on it 
which is set to display the message for X number of seconds and then 
close the form. You could add another property to this form to allow the 
changing of the timer interval, giving the form even more flexibility.

PRIVATE mMessageText AS String

PRIVATE mTimeInterval AS Integer

PUBLIC PROPERTY TimerInterval AS Integer

PRIVATE FUNCTION TimerInterval_Read() AS Integer
     RETURN (mTimerInterval)
END

PRIVATE TimerInterval_Write(Value AS Integer)
     mTimerInterval = Value
     ' Assign the delay from the variable 'mTimerInterval'
     ' OR 'Value', in this case I use the former.
     Timer2.Delay = mTimerInterval
END

PUBLIC PROPERTY MessageText AS String

PRIVATE FUNCTION MessageText_Read() AS String
     RETURN (mMessageText)
END

PRIVATE SUB MessageText_Write(Value AS String)
   mMessageText = Value
   TextArea1.Text = Value

   ' If the user does not set a delay then set the default.
   If TimerInterval = 0 then
      Timer2.Delay = 3
   end if

   ' Ensure the timer is enabled.
   If not Timer2.Enabled then
      Timer2.Enabled = TRUE
   end if
END

PUBLIC SUB Timer2_Timer()
    ME.Close
END


Steve.

Doriano Blengino wrote:
> Szenográdi Norbert Péter ha scritto:
>> Hi all.
>>
>> Im a new member on gambas-user-list.
>>
>> I have some quession:
>> - How can I send a datas to other form..
>>   
> There are two ways.
> 1 - In the project properties, you can set "Controls of forms are 
> public". Once this is done, you can address/refer to controls on other 
> forms by their name, i.e. "Form2.label1.text = ....". This option is 
> global to the project: all the form have public controls or none.
> 
> 2 - As each form is a class, it can have public variables and methods. 
> You can declare PUBLIC variables and access them from outside the form. 
> If you want the form react in some way, this is not enough; after 
> setting a variable you must call a public method declared in the form, 
> which can manipulate its controls. This can be done in a single step: 
> write a public method having some parameter, then call that method 
> passing the data you want. That method can use the data you passed and 
> do what is needed.
> 
> For example, suppose you have a main form which, at some point, opens 
> another form as a "status" form. This StatusForm has a Label1 on it, 
> showing some message. If controls are public (first solution), then you 
> simply write in the main:
> 
>     StatusForm.Label1.Text = "Opening data file..."
>     WAIT   ' this is required to update instantly the screen
> 
> Using the second way runs like this. In the StatusForm code (.class 
> file), declare a public method like this:
> 
>     PUBLIC SUB UpdateMessage(st AS String)
>       Label1.Text = st
>       WAIT
>     END
> 
> At this point, in the main program, you can call: 
> StatusForm.UpdateMessage("Opening data file...")
> 
>> - How can I see any -manual inserted- data in Tableview and/or
>> Gridview..
>>   
> Look at the manual page about GridView - it contains an example on how 
> to set grid "dimensions" (number of row and columns), and fill them by 
> code. About to see them... I don't understand the problem; provided that 
> the event loop is called, then you will see any data a Gridview is 
> filled with.
> 
> Email again if you have still problems.
> 
> 
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> 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