|
-
Nov 28th, 2009, 02:28 PM
#1
Thread Starter
PowerPoster
[RESOLVED] [VB6] - building a new Backcolor property
Last edited by joaquim; Nov 28th, 2009 at 02:36 PM.
-
Nov 28th, 2009, 03:16 PM
#2
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.
-
Nov 28th, 2009, 04:08 PM
#3
Thread Starter
PowerPoster
Re: [VB6] - building a new Backcolor property
 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
-
Nov 28th, 2009, 06:51 PM
#4
Thread Starter
PowerPoster
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?
-
Dec 4th, 2009, 01:19 PM
#5
Thread Starter
PowerPoster
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
-
Dec 4th, 2009, 01:22 PM
#6
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.
-
Dec 6th, 2009, 07:31 AM
#7
Thread Starter
PowerPoster
Re: [RESOLVED] [VB6] - building a new Backcolor property
 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
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
|