jpleroisse
Messages postés1788Date d'inscriptionmardi 7 novembre 2000StatutMembreDernière intervention11 mars 200627 13 sept. 2005 à 14:26
Bonjour,
Tu utilise le contrôle CommonDialog, un contrôle Label et un CommandButton.
Private Sub Command1_Click()
Dim strname As String
With CommonDialog1
.InitDir = "C:\Mes documents\Images"
.Filter = "Images(*.jpg)|*.jpg"
.FileName = "Société.jpg"
End With
strname = CommonDialog1.FileName
Label1 = CommonDialog1.InitDir & strname
End Sub
'Le chemin est récupéré dans la variable strName et placé dans le contrôle Label
cboulas
Messages postés2641Date d'inscriptionmercredi 2 juin 2004StatutMembreDernière intervention 8 janvier 201416 13 sept. 2005 à 15:16
Salut, si tu utilise VB.Net voici un exemple :
Dim MonImage as system.drawing.bitmap
monimage.loadpicture("c:\toto.jpg")
Là on a charger l'image dans une variable maintenant si tu veux concerver l'image et son chemin dans la même variable il faut pour cela créer ton propre objet :
'Création de la nouvelle structure
Structure FullImage
Dim Img as system.drawing.bitmap
Dim Chemin as string
End Structure
Dim Chem as string = "c:\toto.jpg" 'Chemin du fichier image
'Création d'un objet FullImages
Dim MonImage as new FullImage
'Chargement de l'image
MonImage.Img.loadpicture(Chem)
MonImage.Chemin=Chem
Chris...
Web : Firstruner - eMail : [mailto:support@firstruner.com Support]&
pour le commondialog il faut ajouter le composant a ton projet pour ça :
projet => composants => dans la liste tu choisis "Microsoft common dialog control 6.0"
private sub command1_click()
commondialog1.dialogtitle = "Insérer une photo..." ' barre de titre
commondialog1.filter = "Fichiers images (*.jpg)|*.jpg"
commondialog1.filterindex = 1
commondialog.initdir = app.path ' répertoire de l'appli
commondialog1.filename = "" ' ou ce que tu veux
commondialog1.showopen
txtphoto.text = commondialog1.filename
end sub
private sub txtphoto_change()
dim photo as string
image1.picture = loadpicture(photo)
end sub
et suivant la taille de la photo par rapport au contrôle image
renseigner la propriété stretch a true ou false