Gambas France BETA


Pas de compte ? Incription

PictureBox :

Exemple d'utilisation de PictureBox :



Dans l'IDE :



Démo lancée :



Exemple téléchargeable ici : PictureBox

Le programme complet d'où j'ai extrait cette petite démonstration : PhotoManager

Le Code :



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
' Gambas class file

PUBLIC sPhotoPath AS STRING
PUBLIC siPhotos AS SHORT
PUBLIC sPhotoList AS NEW String[]

PUBLIC SUB DirChooser1_Change()

DIM sPhotos AS String[] = [".jpeg", ".jpg", ".gif", ".png"] 'Permissable photos
DIM sDir AS String[] = Dir(DirChooser1.SelectedPath).Sort() 'Get a list of all the files in the selected folder and sort them
DIM siLoop, siPhoto AS SHORT 'Loop variables

siPhotos = 0 'Reset this global variable
sPhotoList.Clear
sPhotoPath = DirChooser1.SelectedPath
FOR siLoop = 0 TO sDir.Max 'Loop through all the files in the selected folder
FOR siPhoto = 0 TO sPhotos.Max 'Loop through the permissable extensions
IF LCase(sDir[siLoop]) ENDS sPhotos[siPhoto] THEN sPhotoList.Add(sDir[siLoop]) 'If the file ends with the permissible extension then add it to sPhotoList array
NEXT
NEXT

IF sPhotoList.Max <> -1 THEN 'If the sPhotoList is not empty then..
siPhotos = sPhotoList.Max
PictureBox1.Picture = Picture[sPhotoPath &/ sPhotoList[0]] 'Set siPhotos to sPhotoList.Max
ELSE
PictureBox1.Picture = NULL
END IF

END

PUBLIC SUB Form_Open()

DIM sChemPict AS STRING

sChemPict = Desktop.GetDirectory("PICTURES") 'découverte du dossier photos
DirChooser1.SelectedPath = Settings["PhotoPath", sChemPict] 'sauvegarde du chemin des photos
sPhotoPath = DirChooser1.SelectedPath 'sPhotoPath = the selected path
Settings.Save
Panel1.Settings = [35, 75]

END

PUBLIC SUB DirChooser1_Activate()

DirChooser1_Change()

END


====================

Navigation :



<-- Accueil du WIKI : <--
<-- Contrôle par Contrôle <--

====================

Documentation :



====================