m2rtech
Messages postés239Date d'inscriptionmercredi 9 octobre 2002StatutMembreDernière intervention20 février 2012
-
24 sept. 2008 à 15:18
m2rtech
Messages postés239Date d'inscriptionmercredi 9 octobre 2002StatutMembreDernière intervention20 février 2012
-
24 sept. 2008 à 16:17
bonjour,
je souhaite intégrer dans une activex une image qui sera paramétrable via les propriétés. Mais je n'ai ne sais pas comment m'y prendre.
en adaptant le code source existant j'ai une erreur.
"des modules d'objets privés ne peuvent être incorporés dans des modules publics...)
Public Property Let Imagepicto(ByVal NewImagepicto As Image)
Image1 = NewImagepicto
PropertyChanged "Imagepicto"
End Property
merci pour votre aide.
A voir également:
Différence entre controle de formulaire et activex
m2rtech
Messages postés239Date d'inscriptionmercredi 9 octobre 2002StatutMembreDernière intervention20 février 2012 24 sept. 2008 à 15:57
Re-salut,
j'ai un "peu" avancé. j'arrive maintenant à charger une image dans mon bouton
en mode compilé (fenetre de test).
je rappel ce que je cherche à faire:
un bouton sur lequel une image est placée à sa droite.
mais j'ai une erreur dans la lecture des propriétés
à cette ligne : Picture = PropBag.ReadProperty("Picture")
voici mon code :
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Caption = PropBag.ReadProperty("Caption", Extender.Name)
Enabled = PropBag.ReadProperty("Enabled", True)
BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
Picture = PropBag.ReadProperty("Picture")
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Caption", Caption, Extender.Name
PropBag.WriteProperty "Enabled", UserControl.Enabled, True
PropBag.WriteProperty "BackColor", Me.BackColor, Ambient.BackColor
PropBag.WriteProperty "Picture", Picture, PicDigits.Picture
End Sub
Public Property Get Picture() As Picture
Set Picture = PicDigits.Picture
End Property
Public Property Set Picture(ByVal New_Picture As Picture)
Set PicDigits.Picture = New_Picture
PropertyChanged "Picture"
End Property
en réponse à PCPT certaine de tes questions sont maintenant quaducs,
depuis mon premier post
mais l'objet image est bien un objet VB
et le nom de la propiété est maintenant Picture.
m2rtech
Messages postés239Date d'inscriptionmercredi 9 octobre 2002StatutMembreDernière intervention20 février 2012 24 sept. 2008 à 16:17
bonjour,
j'ai un phénomère assez curieux,
l'evénement clic ne marche pas bien.
si je fais un clic sur mon bouton, rien,
un deuxieme... et la ça marche(le 2eme 2 à 3 sec plus tard)
je comprend pas ...meme en ajoutant des RaiseEvent Click un peu partout
voici le code complet .
Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCapture Lib "user32" () As Long
Private mBackColor As Long
Public Event Click()
Private Sub Image_hot_Click()
RaiseEvent Click
End Sub
Private Sub PicDigits_Click()
RaiseEvent Click
End Sub
Private Sub Picture1_Click()
RaiseEvent Click
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (X < 0) Or (Y < 0) Or (X > Picture1.Width) Or (Y > Picture1.Height) Then
ReleaseCapture
Picture1 = Image_nor
ElseIf GetCapture() <> Picture1.hWnd Then
SetCapture Picture1.hWnd
Picture1 = Image_hot
End If
End Sub
Private Sub Bouton100_Click()
RaiseEvent Click
End Sub
Private Sub Label1_Click()
RaiseEvent Click
End Sub
Private Sub UserControl_Click()
RaiseEvent Click
End Sub
Private Sub UserControl_Resize()
UserControl.Width = 1470
UserControl.Height = 450
Picture1 = Image_nor
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Caption = PropBag.ReadProperty("Caption", Extender.Name)
Enabled = PropBag.ReadProperty("Enabled", True)
BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
Set Picture = PropBag.ReadProperty("Picture", Nothing)
Picture1 = Image_nor
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Caption", Caption, Extender.Name
PropBag.WriteProperty "Enabled", UserControl.Enabled, True
PropBag.WriteProperty "BackColor", Me.BackColor, Ambient.BackColor
PropBag.WriteProperty "Picture", Picture, Nothing
End Sub
Public Property Get Picture() As Picture
Set Picture = PicDigits.Picture
End Property
Public Property Set Picture(ByVal New_Picture As Picture)
Set PicDigits.Picture = New_Picture
PropertyChanged "Picture"
End Property
Public Property Get Caption() As String
Caption = Label1.Caption
End Property
Public Property Let Caption(ByVal Newcaption As String)
Label1.Caption = Newcaption
PropertyChanged "Caption"
End Property
Public Property Get BackColor() As Long
BackColor = UserControl.BackColor
End Property
Public Property Let BackColor(ByVal NewColor As Long)
UserControl.BackColor = NewColor
PropertyChanged "BackColor" 'on indique le changement au programme
End Property
Public Property Get Enabled() As Boolean
Enabled = UserControl.Enabled
End Property
Public Property Let Enabled(ByVal vNewValue As Boolean)
UserControl.Enabled = vNewValue
PropertyChanged "Enabled"
End Property