|
-
Feb 2nd, 2003, 02:29 PM
#1
Thread Starter
PowerPoster
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:
Dim cGrad1 As RGB
Dim cGrad2 As RGB
Dim ItemRct As RECT
Dim m_BackColor1 As OLE_COLOR
Dim m_BackColor2 As OLE_COLOR
Private Sub UserControl_Paint()
DrawBackColor
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
m_BackColor1 = PropBag.ReadProperty("BackColor1")
m_BackColor2 = PropBag.ReadProperty("BackColor2")
End Sub
Private Sub UserControl_Resize()
DrawBackColor
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("BackColor1", m_BackColor1)
Call PropBag.WriteProperty("BackColor2", m_BackColor2)
Debug.Print "ASDASDASD"
End Sub
Public Property Get BackColor1() As OLE_COLOR
BackColor1 = m_BackColor1
End Property
Public Property Let BackColor1(ByVal New_BackColor1 As OLE_COLOR)
m_BackColor1 = New_BackColor1
PropertyChanged "BackColor1"
cGrad1 = GetRGBColors(GetLngColor(m_BackColor1))
DrawBackColor
End Property
Public Property Get BackColor2() As OLE_COLOR
BackColor2 = m_BackColor2
End Property
Public Property Let BackColor2(ByVal New_BackColor2 As OLE_COLOR)
m_BackColor2 = New_BackColor2
PropertyChanged "BackColor2"
cGrad2 = GetRGBColors(GetLngColor(m_BackColor2))
DrawBackColor
End Property
Sub DrawBackColor()
SetRect ItemRct, 0, UserControl.ScaleHeight / Screen.TwipsPerPixelY, UserControl.ScaleWidth / Screen.TwipsPerPixelX, 0
DrawBackGrad UserControl.hdc, ItemRct, cGrad1, cGrad2, GRADIENT_FILL_RECT_H
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|