Results 1 to 1 of 1

Thread: AxtiveX WriteProperties not working

  1. #1

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    AxtiveX WriteProperties not working

    Never Mind i think i figured out the problem...


    Hola, I've got this simple ocx that draws a gradient background color based on the 2 OLE_COLOR colors the user picks. THe user can set these porperties in the properties window and the background changes, as is should.

    But as soon as i run the program the back color goes to black. I can set the backcolor again thru code and it will stay that color until i close the program, then it changes back to black. It changes to black even though the 2 colors selected in the properties window are not black. I have to go click the colors again to reset it.

    So it seems to me as though the variables are being reset every time the project is opened or closed. So apparently the Writepropeties isnt doing it's job of writing to the Propbag. The Writeproperties is firing becasue i put a Debug.Print in there and it does show up, but for some reason, like i said, the variales are apparently being cleared out and set to 0.


    Here is my code.
    The DrawBackGrad is the function that paints the control with the 2 colors..this works and isnt the problem. And i'm using WinXP Pro if that matters.
    VB Code:
    1. Dim cGrad1 As RGB
    2. Dim cGrad2 As RGB
    3. Dim ItemRct As RECT
    4. Dim m_BackColor1 As OLE_COLOR
    5. Dim m_BackColor2 As OLE_COLOR
    6.  
    7.  
    8. Private Sub UserControl_Paint()
    9. DrawBackColor
    10. End Sub
    11.  
    12. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    13. m_BackColor1 = PropBag.ReadProperty("BackColor1")
    14. m_BackColor2 = PropBag.ReadProperty("BackColor2")
    15. End Sub
    16.  
    17. Private Sub UserControl_Resize()
    18. DrawBackColor
    19. End Sub
    20.  
    21. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    22. Call PropBag.WriteProperty("BackColor1", m_BackColor1)
    23. Call PropBag.WriteProperty("BackColor2", m_BackColor2)
    24. Debug.Print "ASDASDASD"
    25. End Sub
    26. Public Property Get BackColor1() As OLE_COLOR
    27.     BackColor1 = m_BackColor1
    28. End Property
    29.  
    30. Public Property Let BackColor1(ByVal New_BackColor1 As OLE_COLOR)
    31.     m_BackColor1 = New_BackColor1
    32.     PropertyChanged "BackColor1"
    33.   cGrad1 = GetRGBColors(GetLngColor(m_BackColor1))
    34.    DrawBackColor
    35. End Property
    36. Public Property Get BackColor2() As OLE_COLOR
    37.     BackColor2 = m_BackColor2
    38. End Property
    39.  
    40. Public Property Let BackColor2(ByVal New_BackColor2 As OLE_COLOR)
    41.     m_BackColor2 = New_BackColor2
    42.     PropertyChanged "BackColor2"
    43.   cGrad2 = GetRGBColors(GetLngColor(m_BackColor2))
    44.   DrawBackColor
    45. End Property
    46.  
    47. Sub DrawBackColor()
    48. SetRect ItemRct, 0, UserControl.ScaleHeight / Screen.TwipsPerPixelY, UserControl.ScaleWidth / Screen.TwipsPerPixelX, 0
    49. DrawBackGrad UserControl.hdc, ItemRct, cGrad1, cGrad2, GRADIENT_FILL_RECT_H
    50. End Sub

    Thanks!!
    Last edited by Arc; Feb 2nd, 2003 at 03:32 PM.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


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