Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to force a C5 error (Ch 1)
Message
From
22/08/2003 18:55:48
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00822713
Message ID:
00822806
Views:
21
You should post this to a wiki topic.

>A few days back I was [un]lucky enough to isolate a few circumstances that will raise a C5 (fatal exception). The attached code demonstrates how the "state" of contained objects may affect paging.
>
>As is, this code will execute properly. Clicking the command button will sucesfully remove the small container (and the button it contais!).
>
>To force a C5, edit the procedure "RemoveSmallContainer"
>and comment the line "loForm.txtFocus.setfocus" and run the prg again.
>
>
>* C5.prg
>close all
>release all
>clear all
>public frmC5
>frmC5=createobject('subform')
>frmC5.Show
>read events
>cancel
>
>procedure RemoveSmallContainer(loForm,locntBig,locntSmall)
>* To generate a C5 error, comment the line "loForm.txtFocus.setfocus"
>* (below) and rerun
>loForm.txtFocus.setfocus
>locntSmall.Visible=.f.
>locntBig.RemoveObject('cntSmall')
>messagebox([Small Container Removed])
>endproc
>
>define class subBigContainer as container
>left=10
>top=10
>backcolor=rgb(255,255,255)
>add object lblName as label
>lblName.caption=[Big Container]
>add object cntSmall as subSmallContainer
>cntSmall.height=this.height-30
>enddef
>
>define class subSmallContainer as container
>left=20
>top=20
>backcolor=rgb(0,0,255)
>add object lblName as label
>lblName.caption=[Small Container]
>add object cmdRemoveObj as subRemoveObj
>enddef
>
>define class subRemoveObj as commandbutton
>top=30
>left=30
>width = 140
>fontsize=8
>fontname=[Arial]
>caption=[Remove Small Container]
>procedure click
>RemoveSmallContainer(this.parent.parent.parent,this.parent.parent,this.parent)
>endproc
>enddefine
>
>define class subForm as form
>name='frmC5'
>backcolor=rgb(255,0,0)
>autocenter=.t.
>procedure queryunload
>clear events
>endproc
>add object txtFocus as TextBox
>txtFocus.width=1
>txtFocus.height=1
>txtFocus.borderstyle=0
>txtFocus.backstyle=0
>add object cntBig as subBigContainer
>cntBig.width=this.width-30 && This parent is the form
>cntBig.height=this.height-30
>enddefine
>* END C5.PRG
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform