Results 1 to 9 of 9

Thread: PropertyBag Problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403

    Question PropertyBag Problem

    I have this code:
    VB Code:
    1. Private def_backcolor As OLE_COLOR
    2. Private def_caption As String
    3. Private def_font As StdFont
    4. Private def_forecolor As OLE_COLOR
    5. Private def_selected As Boolean
    6.  
    7. Private color As Long
    8. Private sel As Boolean
    9. Private POINTS(15) As POINTAPI
    10.  
    11. Private Const leftcurve As Double = 0.5
    12. Private Const rightcurve As Double = 0.3
    13.  
    14. Public Property Get BackColor() As OLE_COLOR
    15.     BackColor = color
    16. End Property
    17.  
    18. Public Property Let BackColor(new_color As OLE_COLOR)
    19.     color = new_color
    20.     UserControl.BackColor = RndColor(TranslateColor(new_color))
    21.     UserControl.MaskColor = UserControl.BackColor
    22.     Refresh
    23. End Property
    24.  
    25. Public Property Get Caption() As String
    26.     Caption = lblCaption.Caption
    27. End Property
    28.  
    29. Public Property Let Caption(new_caption As String)
    30.     lblCaption.Caption = new_caption
    31.     Refresh
    32. End Property
    33.  
    34. Public Property Get Font() As StdFont
    35.     Set Font = lblCaption.Font
    36. End Property
    37. Public Property Set Font(new_font As StdFont)
    38.     Set lblCaption.Font = new_font
    39.     Refresh
    40. End Property
    41.  
    42. Public Property Get ForeColor() As OLE_COLOR
    43.     ForeColor = UserControl.ForeColor
    44. End Property
    45. Public Property Let ForeColor(new_color As OLE_COLOR)
    46.     UserControl.ForeColor = new_color
    47.     Refresh
    48. End Property
    49.  
    50. Friend Property Get Selected() As Boolean
    51.     Selected = sel
    52. End Property
    53. Friend Property Let Selected(new_state As Boolean)
    54.     sel = new_state
    55.     Refresh
    56. End Property
    57.  
    58. Private Sub UserControl_InitProperties()
    59.     def_backcolor = UserControl.BackColor
    60.     def_caption = ""
    61.     Set def_font = New StdFont
    62.     def_forecolor = UserControl.ForeColor
    63.     def_selected = False
    64.     'hdc = GetDC(UserControl.parent.hwnd)
    65. End Sub
    66.  
    67. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    68.     PropBag.ReadProperty "BackColor", def_backcolor
    69.     PropBag.ReadProperty "Caption", def_caption
    70.     PropBag.ReadProperty "Font", def_font
    71.     PropBag.ReadProperty "ForeColor", def_forecolor
    72.     PropBag.ReadProperty "Selected", def_selected
    73. End Sub
    74.  
    75. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    76.     PropBag.WriteProperty "BackColor", UserControl.BackColor, def_backcolor
    77.     PropBag.WriteProperty "Caption", lblCaption.Caption, def_caption
    78.     PropBag.WriteProperty "Font", lblCaption.Font, def_font
    79.     PropBag.WriteProperty "ForeColor", UserControl.ForeColor, def_forecolor
    80.     PropBag.WriteProperty "Selected", sel, def_selected
    81. End Sub
    For a usercontrol (pretty obvious hmmm ). Anyway, it doesn't work, for some reason it just doesn't store the data. Everytime I open or run the project it's back to defaults. I am not building the usercontrol in it's own seperate project but in a .exe project. Is that the problem? Is there some workaround?

    Many regards in advance,
    Xa0z
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: PropertyBag Problem

    Here is an example that I found:
    Attached Files Attached Files

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403

    Re: PropertyBag Problem

    Quote Originally Posted by dglienna
    Here is an example that I found:
    That sample saves the binary data of the PropertyBag, I thought the propertybag would save itself into a .frx file
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: PropertyBag Problem

    I don't think so.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403

    Re: PropertyBag Problem

    Quote Originally Posted by dglienna
    I don't think so.
    Why is it then that I don't see as many files in my project folder as I have controls on my form? The propertybag of the form is stored together with the propertybags of all the controls on the form into one .frx file, I'm quite sure about that. But I Do have to write a method to write my PropertyBag to that file? that's kinda lame :S
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: PropertyBag Problem

    You probably have to, but I'm not sure, either.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403

    Re: PropertyBag Problem

    Quote Originally Posted by dglienna
    You probably have to, but I'm not sure, either.
    Well thanks for your help anyway buddy! I'll try it eitherway
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  8. #8

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403

    Re: PropertyBag Problem

    lol, now I see it :P thanks alot Woka!
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width