General information
Category:
Forms & Form designer
Odd, it seems that it will hang whenever there's no control to set focus to. If you substitute the button with another object that can not receive focus, such as a shape, it will also hang, the same happens if you set the command's enabled property to false before showing the form, I don't know *why* this happens though.
>Just copy, paste and run this code (no viruses! :).... Then read after the code.
>
>PUBLIC oForm
>LOCAL i, cName
>oForm=CREATEOBJECT("Form")
>oForm.AddObject('Button', 'commandbutton')
>oForm.Button.Visible=.T.
>FOR i=1 TO 5
> cName=SYS(2015)
> oForm.AddObject(cName, "clsContainer")
> WITH oForm. &cName
> .Top=0
> .Left=(i-1)*50+i*20
> .Height=300
> .Width=60
> .Build
> .Visible=.T.
> ENDWITH
>ENDFOR
>oForm.Height=300
>oForm.Width=300
>oForm.Show
>
>DEFINE CLASS clsContainer AS Container
> PROCEDURE Build
> LOCAL i, j, nSize
> nSize=10
> FOR i=1 TO this.Width/nSize
> FOR j=1 TO this.Height/nSize
> cName=SYS(2015)
> this.AddObject(cName, "clsCell")
> WITH this. &cName
> STORE nSize TO .Width, .Height
> .Left=(i-1)*nSize
> .Top=(j-1)*nSize
> .Visible=.T.
> ENDWITH
> ENDFOR
> ENDFOR
> ENDPROC
>ENDDEFINE
>
>DEFINE CLASS clsCell AS Control
> PROCEDURE Click
> this.BackColor=this.BackColor+50
> ENDPROC
>ENDDEFINE
>
>Try to click cells. Is everything OK?
>Then, comment 5th line of this code (oForm.Button.Visible=.T.) and run the code again. Does your VFP hung? Mine too... What is this?
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only