A little problem in ActiveX control programming
-
HI guys I have a couple of questions on creating custom activeX controls. I have a customs activeX control with two constotutent controls An ImageBox and a label. I've exposed two properties namely Picture which corrsponds to the image boxes picture property and Caption which corresponds to teh labels caption. At the moment I'm like setting the picture property by just passing it a string. But that's seriously not how it should be working I mean when you set the Image controls picture property you choose from a file dialog. My code is as below: Option Explicit Public Event Click() Private Sub Image1_Click() RaiseEvent Click End Sub Private Sub UserControl_InitProperties() With Image1 ' .Picture = Nothing End With With lblRouterIP .Caption = "" End With End Sub Private Sub UserControl_ReadProperties(PropBag As PropertyBag) BackColor = PropBag.ReadProperty("BackColor", BackColor) With Image1 .picture = PropBag.ReadProperty("Picture", .picture) End With With lblRouterIP .Caption = PropBag.ReadProperty("caption", .Caption) End With End Sub Private Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("Picture", Image1.picture) Call PropBag.WriteProperty("caption", lblRouterIP.Caption, "") End Sub 'PROBLEM AREA Public Property Get picture() As String picture = Trim(Image1.picture) End Property Public Property Let picture(ByVal img As String) Image1.picture = LoadPicture(img) Call UserControl.PropertyChanged("picture") End Property Public Property Get Caption() As String Caption = lblRouterIP.Caption End Property Public Property Let Caption(ByVal str As String) lblRouterIP.Caption = str Call UserControl.PropertyChanged("Caption") End Property it doesn't make any sense to return a picture as a string. Also lets say that I want to create my own property for this active X control like uh the name of Status that can hold 3 values. How can I do that. I've been using vb6 for a while but this is my initial attempt at activeX programming. I'm using vb 6 and would greatly appreciate the help. :-D
-
HI guys I have a couple of questions on creating custom activeX controls. I have a customs activeX control with two constotutent controls An ImageBox and a label. I've exposed two properties namely Picture which corrsponds to the image boxes picture property and Caption which corresponds to teh labels caption. At the moment I'm like setting the picture property by just passing it a string. But that's seriously not how it should be working I mean when you set the Image controls picture property you choose from a file dialog. My code is as below: Option Explicit Public Event Click() Private Sub Image1_Click() RaiseEvent Click End Sub Private Sub UserControl_InitProperties() With Image1 ' .Picture = Nothing End With With lblRouterIP .Caption = "" End With End Sub Private Sub UserControl_ReadProperties(PropBag As PropertyBag) BackColor = PropBag.ReadProperty("BackColor", BackColor) With Image1 .picture = PropBag.ReadProperty("Picture", .picture) End With With lblRouterIP .Caption = PropBag.ReadProperty("caption", .Caption) End With End Sub Private Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("Picture", Image1.picture) Call PropBag.WriteProperty("caption", lblRouterIP.Caption, "") End Sub 'PROBLEM AREA Public Property Get picture() As String picture = Trim(Image1.picture) End Property Public Property Let picture(ByVal img As String) Image1.picture = LoadPicture(img) Call UserControl.PropertyChanged("picture") End Property Public Property Get Caption() As String Caption = lblRouterIP.Caption End Property Public Property Let Caption(ByVal str As String) lblRouterIP.Caption = str Call UserControl.PropertyChanged("Caption") End Property it doesn't make any sense to return a picture as a string. Also lets say that I want to create my own property for this active X control like uh the name of Status that can hold 3 values. How can I do that. I've been using vb6 for a while but this is my initial attempt at activeX programming. I'm using vb 6 and would greatly appreciate the help. :-D
I don't understand your problem...what is it that you need? You want the user to be able to browse the windows to find the picture? If it's the case, it can be easily be done with the common dialog control...but what is that you really need?
-
I don't understand your problem...what is it that you need? You want the user to be able to browse the windows to find the picture? If it's the case, it can be easily be done with the common dialog control...but what is that you really need?
Actually when I declare teh public Properties for the Picture element of the activeX control what sort of object do I pass to the property like in the following declaration: Public Property Get Picture () AS ???? what do I get teh piucture as in what format a string or an image? I also have another simple problem on how to create instances of the line control at run time through code.
-
Actually when I declare teh public Properties for the Picture element of the activeX control what sort of object do I pass to the property like in the following declaration: Public Property Get Picture () AS ???? what do I get teh piucture as in what format a string or an image? I also have another simple problem on how to create instances of the line control at run time through code.
The Picture component loads a picture file into its image. So to load a picture you usually specify the file name of the picture to be loaded...a file name is a string. So you need to GET the file name as string
Public Property Get Picture () As String