Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. A little problem in ActiveX control programming

A little problem in ActiveX control programming

Scheduled Pinned Locked Moved Visual Basic
helpcomquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gamerPotatoe
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • G gamerPotatoe

      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

      H Offline
      H Offline
      Hadi Fakhreddine
      wrote on last edited by
      #2

      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?

      G 1 Reply Last reply
      0
      • H Hadi Fakhreddine

        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?

        G Offline
        G Offline
        gamerPotatoe
        wrote on last edited by
        #3

        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.

        H 1 Reply Last reply
        0
        • G gamerPotatoe

          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.

          H Offline
          H Offline
          Hadi Fakhreddine
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups