Image dans un ctrl Image qui est dans 1 picturebox dans ctrl utilisateur ne s'af
cs_doyen
Messages postés96Date d'inscriptionjeudi 24 janvier 2002StatutMembreDernière intervention 9 mai 2011
-
13 févr. 2006 à 23:19
PCPT
Messages postés13280Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 2018
-
15 févr. 2006 à 00:20
Soir tout le monde,
voila , j'essaie de faire un controle utilisateur ,et je lui colle un controle PictureBox puis dans ce ctrle je met un controle image ( en fait je met un controle image parce que l'image que je met dedans varie en longueur et donc stretch a true ..) et dans mon controle quand je modifie la longueur du controle l'image suivra.
Ca c'est ma théorie , mais je ne vois jamais l'image ??? Voila le bout de code:
Public Property Set Picture(ByVal New_Picture As Picture)
Set Ctrl_ImgScroll = New_Picture
PropertyChanged "Picture"
End Property
'
Public Property Get Picture() As Picture
Set Picture = Ctrl_ImgScroll
End Property
Merci de l'aide A+
Doyen
A voir également:
Image dans un ctrl Image qui est dans 1 picturebox dans ctrl utilisateur ne s'af
PCPT
Messages postés13280Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201848 13 févr. 2006 à 23:56
salut,
avec le nom de tes contrôles çà serait plus simple....
Ctrl_ImgScroll c'est quoi, cette fameuse image strech? une variable? autre?
à supposer l'image, quel est ton code de resize tant du usercontrole
que de la Picture (container), l'image est bien en 0*0 ? elle est bien
DANS la picture, et non pas juste SUR ?
le usercontrol est en mode transparent?
enfin, toutes les infos qui nous aideraient à te répondre .... (la plateforme de dev en fait parti)
cs_doyen
Messages postés96Date d'inscriptionjeudi 24 janvier 2002StatutMembreDernière intervention 9 mai 2011 14 févr. 2006 à 00:22
Dim Ctrl_ImgScroll As StdPicture
.
.
Set Ctrl_ImgScroll = PropBag.ReadProperty("Picture", Nothing)
.
Call PropBag.WriteProperty("Picture", Ctrl_ImgScroll, Nothing)
Voila pour les declarations , puis suivent les proprietes citeés plus haut et qui vont permettrent d'enregistrer l'image ( en gif ou jpg par ex ) dans le controle image(ImgScroll) , ce controle est dans un autre controle ( picturebox ( picImg)) mais le picture box ne sert que de container au controle image.
Le code du resize :
Private Sub ResizeControl()
On Error Resume Next
PicCurseur.Top 0: PicCurseur.Left 0 'container
PicCurseur.ClsPicCurseur.Width UserControl.ScaleWidth: PicCurseur.Height UserControl.ScaleHeight
picImg.Width PicCurseur.Width ': picImg.Width 34
With ImgScroll
.Width = picImg.Width
.Height = picImg.Height
.Top = 0
.Left = 0
End WithpicImg.Top 21: picImg.Left 0
niveauMin = 21
niveauMax = ((PicCurseur.ScaleHeight - 1) - 21) - picImg.Height
Plage = (niveauMax - niveauMin)
'Call IncreMini(2)
End Sub
PCPT
Messages postés13280Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201848 14 févr. 2006 à 01:06
juste un dernier point....
tout çà pour? avoir une picturebox strechable?
parce que dans ce cas, le usercontrol étant lui-même un container,
pourquoi ne pas charger ton image en variable (comme tu l'as fait) et
directement la dessiner sur le controle?
pour ce :
Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (ByVal
hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long,
ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal
ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal
dwRop As Long) As Long
cs_doyen
Messages postés96Date d'inscriptionjeudi 24 janvier 2002StatutMembreDernière intervention 9 mai 2011 14 févr. 2006 à 13:13
Salut,
j'y avais pas pensé , je vais essayer . Oui c'est seulement pour avoir un picture box strechable comme tu dis .
Mais je comprend pas pourquoi cette image ne s'affiche pas alors que si je la colle directement dans mon controle 'image' a la conception c'est bon , par contre en exploitation , que dalle !!!! j'essaie de comprendre , par curiosité surtout .
Merci encore
A+
doyen
Vous n’avez pas trouvé la réponse que vous recherchez ?
cs_doyen
Messages postés96Date d'inscriptionjeudi 24 janvier 2002StatutMembreDernière intervention 9 mai 2011 14 févr. 2006 à 21:55
Ben le voila , en fait je l'ai commencé pour meubler , c'est un scrollbar 1 picture box ( piccurseur)et dedans 2 images ( ImgBD et ImgHG)puis un picture box ( picimg ) qui contient un ctrl ImageVoila , bien sur il n'est pas developpé , je suis bloqué avec cette image !!!!!A+'============================================================================================================'API'============================================================================================================'API utilisée pour obtenir la position de la sourisPrivate Declare Function GetCursorPos Lib "user32" _ (lpPoint As POINTAPI) As Long'API utilisée pour obtenir les coordonnées d'une zonePrivate Declare Function GetWindowRect Lib "user32" _ (ByVal hwnd As Long, _ lpRECT As RECT) As Long'============================================================================================================'Déclarations de Type pour les API'============================================================================================================Private Type POINTAPI XX As Long YY As LongEnd TypePrivate Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd Type'============================================================================================================'Constantes par défaut'============================================================================================================Const Def_Ctrl_Back_Couleur = &H80000000Const Def_Ctrl_Value = 0Const Def_Ctrl_Min = 0Const Def_Ctrl_Max = 10Const Def_Ctrl_SmallChange = 1Const Def_Ctrl_LargeChange = 5Const Def_Ctrl_Enabled = True'============================================================================================================'Variables du controle'============================================================================================================Dim Ctrl_BackColor As OLE_COLORDim Ctrl_ForeColor As OLE_COLORDim Ctrl_Value As LongDim Ctrl_Min As IntegerDim Ctrl_Max As IntegerDim Ctrl_SmallChange As IntegerDim Ctrl_LargeChange As IntegerDim Ctrl_ScaleImgH As IntegerDim Ctrl_ScaleImgWidth As IntegerDim Ctrl_ImgScroll As StdPictureDim Ctrl_ImgHG As StdPictureDim Ctrl_ImgBD As StdPictureDim Plage As LongDim niveauMin As LongDim niveauMax As LongDim MemoX As SingleDim MemoY As SingleDim BoutonOui As BooleanDim ZonPointeur As IntegerDim Ctrl_Enabled As Boolean'============================================================================================================'Declaration des evenements'============================================================================================================Event KeyDown(KeyCode As Integer, Shift As Integer)Event KeyPress(KeyAscii As Integer)Event KeyUp(KeyCode As Integer, Shift As Integer)Event Click()Event DblClick()Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Event Resize()Event Scroll()Event Change(State As Integer, Sorte As Integer)'============================================================================================================' INIT Property'============================================================================================================Private Sub UserControl_InitProperties()Ctrl_BackColor = Def_Ctrl_Back_CouleurCtrl_ForeColor = Def_Ctrl_Fore_CouleurCtrl_Value = Def_Ctrl_ValueCtrl_Min = Def_Ctrl_MinCtrl_Max = Def_Ctrl_MaxCtrl_SmallChange = Def_Ctrl_SmallChangeCtrl_LargeChange = Def_Ctrl_LargeChangeCtrl_BorderUp = Def_Ctrl_BorderUpCtrl_BorderDown = Def_Ctrl_BorderDownCtrl_Enabled = Def_Ctrl_EnabledEnd SubPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)Ctrl_Value = PropBag.ReadProperty("Value", Def_Ctrl_Value)Ctrl_Enabled = PropBag.ReadProperty("CtrlEnabled", Def_Ctrl_Enabled)Ctrl_Min = PropBag.ReadProperty("Min", Def_Ctrl_Min)Ctrl_Max = PropBag.ReadProperty("Max", Def_Ctrl_Max)Ctrl_SmallChange = PropBag.ReadProperty("SmallChange", Def_Ctrl_SmallChange)Ctrl_LargeChange = PropBag.ReadProperty("LargeChange", Def_Ctrl_LargeChange)Ctrl_BackColor = PropBag.ReadProperty("BackColor", Def_Ctrl_Back_Couleur)Set Ctrl_ImgBD = PropBag.ReadProperty("PictureMaxi", Nothing)Set Ctrl_ImgHG = PropBag.ReadProperty("PictureMini", Nothing)'Set Ctrl_ImgScroll = PropBag.ReadProperty("Picture", Nothing)Set Me.Picture = PropBag.ReadProperty("Picture", Nothing)End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag)Call PropBag.WriteProperty("BackColor", Ctrl_BackColor, Def_Ctrl_Back_Couleur)Call PropBag.WriteProperty("SmallChange", Ctrl_SmallChange, Def_Ctrl_SmallChange)Call PropBag.WriteProperty("LargeChange", Ctrl_LargeChange, Def_Ctrl_LargeChange)Call PropBag.WriteProperty("Min", Ctrl_Min, Def_Ctrl_Min)Call PropBag.WriteProperty("Max", Ctrl_Max, Def_Ctrl_Max)Call PropBag.WriteProperty("Value", Ctrl_Value, Def_Ctrl_Value)Call PropBag.WriteProperty("CtrlEnabled", Ctrl_Enabled, Def_Ctrl_Enabled)'Call PropBag.WriteProperty("Picture", Ctrl_ImgScroll, Nothing)Call PropBag.WriteProperty("PictureMaxi", Ctrl_ImgBD, Nothing)Call PropBag.WriteProperty("PictureMini", Ctrl_ImgHG, Nothing)Call PropBag.WriteProperty("Picture", Me.Picture, Nothing)End Sub'============================================================================================================'Proprites du controle'============================================================================================================Public Property Let BackColor(ByVal New_CtrlBackColor As OLE_COLOR)Ctrl_BackColor = New_CtrlBackColorUserControl.BackColor = Ctrl_BackColorPicCurseur.BackColor = Ctrl_BackColorCall RefreshPropertyChanged "BackColor"End PropertyPublic Property Get BackColor() As OLE_COLORBackColor = Ctrl_BackColorEnd PropertyPublic Property Let Enabled(ByVal New_CtrlEnabled As Boolean)Ctrl_Enabled = New_CtrlEnabledRefreshPropertyChanged "CtrlEnabled"End PropertyPublic Property Get Enabled() As BooleanEnabled = Ctrl_EnabledEnd PropertyPublic Property Let Min(New_CtrlMin As Integer)If New_CtrlMin > Ctrl_Max Then MsgBox ("Valeur MIN Doit etre < a Valeur MAX"): Exit PropertyIf Ctrl_Value < New_CtrlMin Then Ctrl_Value = New_CtrlMin PropertyChanged "Value"End IfCtrl_Min = New_CtrlMinPropertyChanged "Min"End PropertyPublic Property Get Min() As IntegerMin = Ctrl_MinEnd PropertyPublic Property Let Max(New_CtrlMax As Integer)If New_CtrlMax < Ctrl_Min Then MsgBox ("Valeur MAX Doit etre > a Valeur MIN"): Exit PropertyIf Ctrl_Value > New_CtrlMax Then Ctrl_Value = New_CtrlMax PropertyChanged "Value"End IfCtrl_Max = New_CtrlMaxPropertyChanged "Max"End PropertyPublic Property Get Max() As IntegerMax = Ctrl_MaxEnd PropertyPublic Property Let SmallChange(New_CtrlSmallChange As Integer)Ctrl_SmallChange = New_CtrlSmallChangePropertyChanged "SmallChange"End PropertyPublic Property Get SmallChange() As IntegerSmallChange = Ctrl_SmallChangeEnd PropertyPublic Property Let LargeChange(New_CtrlLargeChange As Integer)Ctrl_LargeChange = New_CtrlLargeChangePropertyChanged "LargeChange"End PropertyPublic Property Get LargeChange() As IntegerLargeChange = Ctrl_LargeChangeEnd PropertyPublic Property Let value(New_CtrlValue As Integer)If New_CtrlValue < Ctrl_Min Then New_CtrlValue = Ctrl_MinEnd IfIf New_CtrlValue > Ctrl_Max Then New_CtrlValue = Ctrl_MaxEnd IfCtrl_Value = New_CtrlValueCall ResizeControlPropertyChanged "Value"End PropertyPublic Property Get value() As Integervalue = Ctrl_ValueEnd PropertyPublic Property Set Picture(ByVal New_Picture As Picture)Set Ctrl_ImgScroll = New_PicturePropertyChanged "Picture"End Property'Public Property Get Picture() As PictureSet Picture = Ctrl_ImgScrollEnd PropertyPublic Property Set PictureMini(ByVal New_Picture As Picture)Set Ctrl_ImgHG = New_PicturePropertyChanged "PictureMini"ImgHG.RefreshEnd Property'Public Property Get PictureMini() As PictureSet PictureMini = Ctrl_ImgHGEnd PropertyPublic Property Set PictureMaxi(ByVal New_Picture As Picture)Set Ctrl_ImgBD = New_PictureImgBD.RefreshPropertyChanged "PictureMaxi"End Property'Public Property Get PictureMaxi() As PictureSet PictureMaxi = Ctrl_ImgBDImgBD.RefreshEnd PropertyPublic Property Get Autosize() As Boolean Autosize = m_AutoSizeEnd PropertyPublic Property Let Autosize(ByVal New_AutoSize As Boolean) m_AutoSize = New_AutoSize PropertyChanged "AutoSize"End Property'============================================================================================================'Gestion des evenements du controle'============================================================================================================Private Sub picImg_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Dim PosCurs As POINTAPI, RectPic As RECT, B As Integer, i As IntegerGetCursorPos PosCursGetWindowRect PicCurseur.hwnd, RectPic'Set picImg.Picture = Ctrl_ImgDown'' Memo de la dif entre le point de clic de la souris et le debut ( left) du control image cette dif sera utilisée ds mousemove'ZonPointeur = PosCurs.XX - (RectPic.Top + picImg.Top)BoutonOui = TrueRaiseEvent MouseDown(Button, Shift, X, Y)End SubPrivate Sub picImg_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Dim PosCurs As POINTAPI, RectPic As RECT, B As Integer, i As Integer, Increment, Position, CalculIf Not BoutonOui Then Exit SubGetCursorPos PosCursGetWindowRect PicCurseur.hwnd, RectPic' Calcul de la position relative de la souris ( B )'B = (PosCurs.YY - ZonPointeur) - RectPic.TopIf B < niveauMin Then B = niveauMinIf B > niveauMax Then B = niveauMaxPicCurseur.AutoRedraw = TruepicImg.AutoRedraw = True'Increment = Plage / (Ctrl_Max - Ctrl_Min)Ctrl_Value = ((B - 21) / Increment) + Ctrl_MinIf B >= niveauMax Then Ctrl_Value = Ctrl_MaxIf B = Ctrl_Max Then Ctrl_Value = Ctrl_Max Timer1.Enabled = False End If Else Exit Sub End IfCall BougeIncrement(picImg, Ctrl_Value)MemoX = X: MemoY = YRaiseEvent MouseDown(Button, Shift, X, Y)Timer1.Enabled = TrueEnd SubPrivate Sub ImgScroll_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Dim PosCurs As POINTAPI, RectPic As RECT, B As Integer, i As IntegerGetCursorPos PosCursGetWindowRect PicCurseur.hwnd, RectPic'' Memo de la dif entre le point de clic de la souris et le debut ( left) du control image cette dif sera utilisée ds mousemove'ZonPointeur = PosCurs.YY - (RectPic.Top + picImg.Top)BoutonOui = TrueRaiseEvent MouseDown(Button, Shift, X, Y)End SubPrivate Sub ImgScroll_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Dim PosCurs As POINTAPI, RectPic As RECT, B As Integer, i As Integer, Increment, Position, CalculIf Not BoutonOui Then Exit SubGetCursorPos PosCursGetWindowRect PicCurseur.hwnd, RectPic' Calcul de la position relative de la souris ( B )'B = (PosCurs.YY - ZonPointeur) - RectPic.TopIf B < niveauMin Then B = niveauMinIf B > niveauMax Then B = niveauMaxPicCurseur.AutoRedraw = TruepicImg.AutoRedraw = True'Increment = Plage / (Ctrl_Max - Ctrl_Min)Ctrl_Value = ((B - 21) / Increment) + Ctrl_MinIf B >= niveauMax Then Ctrl_Value = Ctrl_MaxIf B