Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to force a C5 error (Ch 1)
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
How to force a C5 error (Ch 1)
Divers
Thread ID:
00822713
Message ID:
00822713
Vues:
51
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 
Imagination is more important than knowledge
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform