Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Design time re-size
Message
From
18/06/2009 10:50:41
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01406083
Message ID:
01406873
Views:
81
Naomi --

Turns out that even with FoxObject you can still get C5 errors.

Thus, I do not use the construction
For Each loObject in Objects FoxObject
. If you browsed my code, you'll see that instead I use a counter and an index ...
		For lnI = 1 To lnCount
		loChild = loParent.Objects(lnI)
I have found in writing PEMEditor that For Each loObject in Objects FoxObject can create C5 errors -- in fact, demonstrating this was kind of interesting. In my instance, I would stop my code on this statement, and then do anything I wanted, as I would at any time in the IDE. After executing the statement, I could observe that a new oddly named property was created in the Property Window ("_NewENum") and then clicking on just about anything else in my session would crash VFP.

When I removed this type of looping from PEMEditor, all C5 errors happily disappeared.

Of course, the loop I'm using is a little more cumbersome, since I have to determine the number of items, but that's a small price to pay.


>Hi Jim,
>
>To avoid C005 errors did you try adding FOXOBJECT to FOR EACH loop?
>
>>Koen --
>>
>>Yes, I do have a very special case -- I have a form designed in font size 8, which I would like to use in a presentation with font size 14. (This is my PEM Editor tool). Turns out that the form starts out small enough that it can handle being (almost) doubled in size.
>>
>>So, below is the little class I've come up with. Drop it on a sample form, and do.
>>
>> .Run (nn, 8) where nn is the new fontsize
>>
>>**************************************************
>>*-- Class:        changefontsize 
>>*-- ParentClass:  custom
>>*-- BaseClass:    custom
>>*-- Time Stamp:   06/16/09 02:12:02 PM
>>*
>>*
>>DEFINE CLASS changefontsize AS custom
>>
>>
>>	Name = "changefontsize"
>>
>>
>>	PROCEDURE run
>>		* Added: 06/16/2009
>>		*========================
>>
>>		Lparameters tnNewFontSize, tnDefaultFontSize
>>
>>		With This
>>			.Update ('Save Anchor', Thisform)
>>			.Update ('Change FontSize', Thisform, tnNewFontSize, tnDefaultFontSize)
>>			.Update ('Restore Anchor', Thisform)
>>		Endwith
>>	ENDPROC
>>
>>
>>
>>
>>	*-- Updates all objects on this form to a new font size -- changing their size and position as well
>>	PROCEDURE update
>>		* Added: 06/16/2009
>>		*========================
>>		Lparameters tcStyle, toParent, tnNewFontSize, tnDefaultFontSize
>>
>>		Local  ;
>>			loChild AS Object	,;
>>			loParent AS Object
>>		Local lbChangeFontsize, lnCount, lnI
>>
>>		loParent = toParent
>>
>>		*** JRN 06/16/09 : get count for number of children
>>		With loParent
>>			Do Case
>>				Case Not Pemstatus(loParent, 'Objects', 5)
>>					lnCount = 0
>>				Case Pemstatus(loParent, 'ControlCount', 5)
>>					lnCount = .ControlCount
>>				Case Inlist(Lower(.BaseClass),[pageframe])
>>					lnCount = .PageCount
>>				Case Inlist(Lower(.BaseClass),[grid])
>>					lnCount = .ColumnCount
>>				Case Inlist(Lower(.BaseClass),[optiongroup],[commandgroup])
>>					lnCount = .ButtonCount
>>				Otherwise
>>					lnCount = 0
>>			Endcase
>>		Endwith
>>
>>		*** JRN 06/16/09 : Loop thru children, avoiding potential C5 errors if using For Each
>>		If lnCount # 0 And "O" = Type("loParent.Objects(1)")
>>			For lnI = 1 To lnCount
>>				loChild = loParent.Objects(lnI)
>>				This.Update (tcStyle, loChild, tnNewFontSize, tnDefaultFontSize)
>>			Endfor
>>		Endif
>>
>>		If Not Pemstatus (loParent, 'Top', 5)
>>			Return
>>		Endif
>>
>>		With loParent
>>			Do Case
>>				Case tcStyle = 'Save Anchor'
>>					If Pemstatus (loParent, 'Anchor', 5)
>>						.AddProperty ('n_original_anchor', .Anchor)
>>						.Anchor = 0
>>					Endif
>>				Case tcStyle = 'Restore Anchor'
>>					If Pemstatus (loParent, 'Anchor', 5)
>>						.Anchor = .n_original_anchor
>>					Endif
>>				Case tcStyle = 'Change FontSize'
>>					lbChangeFontsize = Pemstatus (loParent, 'FontSize', 5)
>>					If Not Pemstatus (loParent, 'n_original_width', 5)
>>						.AddProperty ('n_original_top', .Top)
>>						.AddProperty ('n_original_left', .Left)
>>						.AddProperty ('n_original_height', .Height)
>>						.AddProperty ('n_original_width', .Width)
>>						If lbChangeFontsize 
>>							.AddProperty ('n_original_fontsize', .FontSize)
>>						Endif
>>					Endif
>>
>>					.Top 	= .n_original_top * tnNewFontSize / tnDefaultFontSize
>>					.Left 	= .n_original_Left * tnNewFontSize / tnDefaultFontSize
>>					.Height = .n_original_Height * tnNewFontSize / tnDefaultFontSize
>>					.Width 	= .n_original_width * tnNewFontSize / tnDefaultFontSize
>>					If lbChangeFontsize 
>>						.FontSize = .n_original_fontsize * tnNewFontSize / tnDefaultFontSize
>>					Endif
>>			Endcase
>>		Endwith
>>	ENDPROC
>>ENDDEFINE
>>*
>>*-- EndDefine: changefontsize
>>**************************************************
>>
>>
>>
>>
>>
>>>James,
>>>
>>>quote
>>>But it won't change the position of the controls -- as the fontsize grows, I want the form to grow as well, to have all the controls on the form to expand and move proportionally so that, in effect, it looks like it had previously, only larger.
>>>unquote
>>>
>>>Are you sure, that will not only need an intensive trouble with anchors but will also need a very special form design. I would not think of even start to think how that has to be programmed in VFP. Maybe it is a start to make use of the Windows magnifier technique.
>>>
>>>Do keep me posted when you have skinned this goat.
>>>
>>>Regards,
>>>
>>>Koen
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform