Discussion:
Get Method Issue with Hidden Property
Ken Dibble
2018-03-27 18:21:10 UTC
Permalink
VFP 9 SP 1, running on Win 7 Ultimate SP 1.

I know that there can be issues with hidden object properties; that's
why I give the base class "Set" and "Get" methods to deal with them.
That's always supposed to work, right?

So today somebody's software blew up on the "Get" method for a Shape object:

This is in my resize code (I created this long before VFP had
Anchors, and I haven't bothered to change it; the cause of the
problem is not that I'm not using Anchors, and the correct solution
for the actual problem cannot be to ditch my code and use Anchors
instead, even though some people may suggest that.)

This seems to have happened because of some bizarre anomaly where a
user was previewing a report using the standard VFP report preview
window. That report was called from a window that was opened by
another window, both of which are In-Desktop windows inside my
custom-made main window (I don't use _SCREEN). She closed the preview
window, whereupon a shape that is ON THE MAIN WINDOW, not on the
window that should have gotten focus, somehow executed its Resize()
method--so she probably nudged the border of the main window somehow
while playing with the report preview.

My shape subclass did this:

thepercent = THIS.ObtainAValue("PercentWidth")

* PercentWidth is a hidden property of the baseclass. The baseclass
code is this:
PROCEDURE ObtainAValue
LPARAMETERS cTheProperty

IF PEMSTATUS(THIS,cTheProperty,5) = .T.
* Property exists; the IF statement just said so...
RETURN THIS.&cTheProperty && Error 1734 "Property
PERCENTWIDTH is not found"
ELSE
RETURN 0
ENDIF
ENDPROC

That's all of the code involved; I'm not leaving anything out.

I can't reproduce this myself.

Needless to say, various users have resized their various forms
bazillions of times, thereby running this code bazillions of times
*times* the number of times Resize() gets called when you're messing
with the borders of a form, without having this happen. This is the
kind of stuff that just irks me. I've seen it before; built-in VFP
functions just flat-out lie, leaving my code with nothing to
trust--but it only happens once in a blue moon.

Any thoughts (other than "Use anchors instead"?)

Thanks.

Ken Dibble
www.stic-cil.org


_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Fernando D. Bozzo
2018-03-27 22:00:51 UTC
Permalink
Hi Ken:

Sometimes, for unknown reasons, VFP have trouble with hidden properties,
and when this happens one of the fixes is unhidding the property, making it
public.

May be not the best solution, but it's better a bad solution than no
solution at all.
Post by Ken Dibble
VFP 9 SP 1, running on Win 7 Ultimate SP 1.
I know that there can be issues with hidden object properties; that's why
I give the base class "Set" and "Get" methods to deal with them. That's
always supposed to work, right?
So today somebody's software blew up on the "Get" method for a Shape
This is in my resize code (I created this long before VFP had Anchors, and
I haven't bothered to change it; the cause of the problem is not that I'm
not using Anchors, and the correct solution for the actual problem cannot
be to ditch my code and use Anchors instead, even though some people may
suggest that.)
This seems to have happened because of some bizarre anomaly where a user
was previewing a report using the standard VFP report preview window. That
report was called from a window that was opened by another window, both of
which are In-Desktop windows inside my custom-made main window (I don't use
_SCREEN). She closed the preview window, whereupon a shape that is ON THE
MAIN WINDOW, not on the window that should have gotten focus, somehow
executed its Resize() method--so she probably nudged the border of the main
window somehow while playing with the report preview.
thepercent = THIS.ObtainAValue("PercentWidth")
* PercentWidth is a hidden property of the baseclass. The baseclass code
PROCEDURE ObtainAValue
LPARAMETERS cTheProperty
IF PEMSTATUS(THIS,cTheProperty,5) = .T.
* Property exists; the IF statement just said so...
RETURN THIS.&cTheProperty && Error 1734 "Property PERCENTWIDTH
is not found"
ELSE
RETURN 0
ENDIF
ENDPROC
That's all of the code involved; I'm not leaving anything out.
I can't reproduce this myself.
Needless to say, various users have resized their various forms bazillions
of times, thereby running this code bazillions of times *times* the number
of times Resize() gets called when you're messing with the borders of a
form, without having this happen. This is the kind of stuff that just irks
me. I've seen it before; built-in VFP functions just flat-out lie, leaving
my code with nothing to trust--but it only happens once in a blue moon.
Any thoughts (other than "Use anchors instead"?)
Thanks.
Ken Dibble
www.stic-cil.org
[excessive quoting removed by server]

_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAGQ_JunVsEmsHD8YjjGFgT5ZNJoTobe5uZ0toRXh=***@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Continue reading on narkive:
Loading...