[RESOLVED] [VB6] - building a new Backcolor property
i build a new property:
Code:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
sprBackColor = PropBag.ReadProperty("sprBackColor", lngBackColor)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "sprBackColor", sprBackColor, lngBackColor
End Sub
Public Property Get sprBackColor() As OLE_COLOR
sprBackColor = lngBackColor
End Property
Public Property Let sprBackColor(newBackColor As OLE_COLOR)
lngBackColor = newBackColor
Call ShowImage
PropertyChanged "sprBackColor"
End Property
my question is: why these property don't save the value from project mode to the run mode?:(
(i always recive black color :(. but if i change in project mode works fine(in project mode). and if i change in run mode, works fine. but if i change for vbyellow, in project mode, i recive black in run mode:()
thanks
Re: [VB6] - building a new Backcolor property
Because of this line: PropBag.WriteProperty "sprBackColor", sprBackColor, lngBackColor
The 3rd parameter is the default value. If sprBackColor=lngBackColor, then VB does not write to the propertybag and nothing is written for that property. Well, sprBackColor will always = lngBackColor when writing, so nothing is written. Therefore, the value read is always zero/black.
Recommend changing your routines....
Code:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
sprBackColor = PropBag.ReadProperty("sprBackColor", vbBlack)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "sprBackColor", lngBackColor, vbBlack
End Sub
The above says that when writing: If lngBackColor is Black, don't write the property else write lngBackColor. When reading: If the property does not exist, use Black else use the value that was written.
Re: [VB6] - building a new Backcolor property
Quote:
Originally Posted by
LaVolpe
Because of this line: PropBag.WriteProperty "sprBackColor", sprBackColor, lngBackColor
The 3rd parameter is the default value. If sprBackColor=lngBackColor, then VB does not write to the propertybag and nothing is written for that property. Well, sprBackColor will always = lngBackColor when writing, so nothing is written. Therefore, the value read is always zero/black.
Recommend changing your routines....
Code:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
sprBackColor = PropBag.ReadProperty("sprBackColor", vbBlack)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "sprBackColor", lngBackColor, vbBlack
End Sub
The above says that when writing: If lngBackColor is Black, don't write the property else write lngBackColor. When reading: If the property does not exist, use Black else use the value that was written.
we use, always, a default value and not a variable;)
thank you for the advice.
it's working, thanks
Re: [RESOLVED] [VB6] - building a new Backcolor property
i change my property name(only the name): from sprBackColor to BackColor.
i need ask these: use the VB6, automatic, change to backcolor?
is because, the backcolor be a property keyword?
Re: [RESOLVED] [VB6] - building a new Backcolor property
what i mean was: i have 1 property named: "BackColor". but my VB6 change it for "backcolor". why? is because to be a keyword?
thanks
Re: [RESOLVED] [VB6] - building a new Backcolor property
I see this sometimes. Search your entire ocx project looking for backcolor. When found, ensure it is always spelled the same way. I suspect that "backcolor" is used somewhere in your declaration sections, either in an API parameter, a UDT member, an Enumeration member or something else.
Re: [RESOLVED] [VB6] - building a new Backcolor property
Quote:
Originally Posted by
LaVolpe
I see this sometimes. Search your entire ocx project looking for backcolor. When found, ensure it is always spelled the same way. I suspect that "backcolor" is used somewhere in your declaration sections, either in an API parameter, a UDT member, an Enumeration member or something else.
thanks now i resolve these "bug". i have more problems like these, but the most important was these;)
thanks