Gambas France BETA


Pas de compte ? Incription

Exemple simple d'un Panneau de Boutons

À propos de ce code

Un simple Panneau avec 12 Boutons,
avec des Commandes rudimentaires.
Le tout, construit dans le Code,
sans surcharge de commentaires.

Reivillo..

Code source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
' Gambas class file

PUBLIC MyPnlBtn AS NEW Panel(ME)
PUBLIC MyCtrlPanel AS NEW Button(ME) AS "MyCtrlPanel"
PUBLIC MyTxtBox AS NEW TextBox(ME)
PUBLIC MyButton AS NEW Button[]
PUBLIC iIdxBtn AS INTEGER = 0

PUBLIC SUB Form_Open()

DIM iLoopFor AS INTEGER = 0

MyPnlBtn.W = ME.W
MyPnlBtn.H = 48
MyPnlBtn.Arrangement = Arrange.Horizontal
MyPnlBtn.Margin = TRUE
MyPnlBtn.Border = Border.Plain

MyCtrlPanel.H = 24
MyCtrlPanel.Border = Border.Plain
MyCtrlPanel.Text = "Cacher les Boutons"

MyTxtBox.Y = 128
MyTxtBox.W = ME.W
MyTxtBox.H = 24
MyTxtBox.Alignment = Align.Center

ME.W = MyPnlBtn.W
ME.Arrangement = Arrange.Vertical
ME.Margin = TRUE

FOR iLoopFor = iLoopFor TO 11
AddElm
NEXT

END

PUBLIC SUB AddElm()

iIdxBtn = MyButton.Count
MyButton.Add(NULL, MyButton.Count)
MyButton[iIdxBtn] = NEW Button(MyPnlBtn) AS "GrpMyButton"
WITH MyButton[iIdxBtn]
.W = 23
.Border = Border.Plain
.Text = "Btn\n" & iIdxBtn
.tag = iIdxBtn
.X = iIdxBtn * 32
END WITH

END

PUBLIC SUB GrpMyButton_MouseUp()

DIM BtnMouse AS STRING = ""

SELECT CASE Mouse.Left
CASE TRUE
BtnMouse = " < Gauche > "
CASE FALSE
SELECT CASE Mouse.Middle
CASE TRUE
BtnMouse = " < Milieu > "
CASE FALSE
BtnMouse = " < Droit > "
END SELECT
END SELECT

MyTxtBox.Text = "Vous avez Cliquez" & BtnMouse & "sur le Bouton " & LAST.tag
LAST.background = Color.Red

END

PUBLIC SUB GrpMyButton_Enter()

MyTxtBox.Text = "Survol du Bouton " & LAST.tag
LAST.background = Color.Green

END

PUBLIC SUB GrpMyButton_Leave()

MyTxtBox.Text = "Vous avez Quitter les Boutons"
LAST.background = Color.Default

END

PUBLIC SUB MyCtrlPanel_MouseUp()

IF LAST.Text = "Cacher les Boutons" THEN
MyPnlBtn.hide
LAST.Text = "Montrer les Boutons"
MyTxtBox.Text = "Vous Avez Caché les Boutons"
ELSE
MyPnlBtn.Show
LAST.Text = "Cacher les Boutons"
ENDIF

END

Commentaires