Page loading

Share your opinion
What do you think about gambaslinux.fr?
 
Interesting
It miss some informations
Excellent website
Results
WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
Library
Create own software - Both way to program
BOTH WAY TO PROGRAM

Hye,
Today, I propose to you to compare two mode to program a little application.

We code a little application with 3 picturebox in a form. And we 'll can Click to display a message in the IDE Gambas console.

You have Two way :

1)Create App with Gambas IDE (like WYSWYG)
-create 3 picturebox
-choose for each picturebox your picture, size, x,y, etc...
-Create for each picturebox the event click(there is 3 similary functions)

It's not the great job because we have :
-3 identics functions
-Source code is too heavy
-Impossible to add new picturebox without IDE.

Another way is very interesting and I show you now.

2) Create with a click on a button many picturebox as you want.
Here the step :
Declare a pciturebox as :

PUBLIC mypict as picturebox

now our button click event:
PUBLIC SUB Button_Click()
mypict = NEW picturebox(me) AS "boite1"
mypict.background = &HFFFFFF&
mypict.X = 234
mypict.picture = picture["/home/toto/bobi.jpg"]
END

We comment this source code line very important :
mypict = NEW picturebox(me) AS "boite1"

Mypict will be a new picturebox with events known as this :
PUBLIC SUB boite_click()
print "I'have clicked on picturebox!"
END

Do you understand ? yes ? well, we continu.

I create 5 picturebox with 5 click on the button and I click on  picturebox 4.
how the soft know which picturebox I have clicked ?
Simply affect the TAG property with a couter.
as this :
PUBLIC mykey as integer = 1
well, you write this code :
mypict.Tag = mykey
INC key 'increment mykey for the next time

Now it's easy to know which picture has been cliqued.
by the command
LAST.Tag

you can code as this :
PUBLIC SUB boite_click()
print "I have cliqued on the picturebox " & Last.Tag
END

Thanks for your attention.
regards
wink


Creation date : 11/06/2010 @ 21:41
Last update : 11/06/2010 @ 21:42
Category : Create own software
Page read 5860 times


Print the article Print the article


react.gifReactions to this article

Nobody gave a comment yet.
Be the first one to do it!


QUICK MENU
SEARCH




LANGUAGE
COMPONENTS
Other
LANGUAGE
Where, who?
VISITS

   visitors

   visitors online

ARCHIVES GAMBAS 1/2
^ Top ^