Discussion:
Strange behavior of user controls
(too old to reply)
Ivar
2011-09-22 20:30:47 UTC
Permalink
Hi all.

I have a weird problem that I will do my best to describe

I have written an app on a machine with Winders 7 64 using VB6 service pack
5
The app has two UserControls (Done by me) One is entirely graphical using
APIs to do the drawing and one contains a textbox and a shape control
Both controls have default properties that are stored as constants in the
usercontrol code EG: Private Const m_Def_Caption = "Hello World"
When designing a form I put a UserControl on the form and the UserControl
shows it's default properties EG: the caption shows "Hello World"
Still in the form design window of VB6 I change the properties of the
UserControl (As in, put "Have a nice day" in the caption property ) and the
control on the form (In the IDE) shows the new property.
I run The App in the IDE and the usercontrols displays properly. Caption
reads "Have a nice day"
I compile the app and all is well with the usercontrol displaying the
properties as they should (on the development machine)
I install the app on two other machines, both running Winders XP and all
usercontrols (both types) show up with their default properties. As in the
caption being displayed is "Hello World" instead of "Have a nice day"
It seems as if the app is forgetting the properties set at design time
I've never seen this before, but this is the first time I have run an app on
another machine that I have developed using VB6 on Winders 7
If, for example I put a piece of code in the app such as:
Private Sub Form_Activate()
MyControl.Caption = "Have a nice Day"
End Sub
Then the compiled app on the other XP machines will display the correct
caption.
I've been using these two user controls for years and I have never seen this
before
Does anybody have any idea why the usercontrols will show with default
properties instead of the set properties?

Thanks for any replies

Ivar
Nobody
2011-09-23 20:31:18 UTC
Permalink
Post by Ivar
I've been using these two user controls for years and I have never seen
this before
Does anybody have any idea why the usercontrols will show with default
properties instead of the set properties?
Thanks for any replies
This could happen if you don't have code to save/restore/init the properties
in these events:

InitProperties
ReadProperties
WriteProperties

Try using "VB6 ActiveX Ctrl Interface Wizard" Add-in in a new UserControl,
which generates the code for you. Just start the Wizard, and click Next(You
can keep clicking on Next till the end if you wish).
Ivar
2011-09-23 22:27:38 UTC
Permalink
Yep, it's all there
These two controls have been used for years unchanged and it's never
happened before until I put the compiled app made on Windows 7 64 on two XP
machines.
The only explanation I can think of is some issue with apps created on Win 7
running on XP, but that's just a guess

Thanks anyway

Ivar
Nobody
2011-09-25 01:08:32 UTC
Permalink
Post by Ivar
Yep, it's all there
These two controls have been used for years unchanged and it's never
happened before until I put the compiled app made on Windows 7 64 on two
XP machines.
The only explanation I can think of is some issue with apps created on Win
7 running on XP, but that's just a guess
Perhaps the FRX file for the form became corrupted. First, make a backup,
then open the FRM file with Notepad and search for "frx". You will find the
list of properties that VB stores in that file. These are usually binary
properties like Pictures and Icons. Do not edit the file in Notepad, but
rather, open the project in VB, and delete the contents of these properties
and save. After that, search the FRM file again, and if all references to
"frx" are gone, then it's safe to delete the FRX file.

Loading...