Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form flashed and disappered
Message
From
30/07/2002 04:01:22
 
 
To
29/07/2002 14:17:20
Irv Adams
MSC Managed Care, Inc.
Florida, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00682995
Message ID:
00683834
Views:
33
>Zlatin...this sounds interesting...could you explain this some more? Are you saying I could class a Form that would automatically prevent anyone from instantiating it twice if it's already Open and even though it's not Modal?
>
>Thanks,
>
>-Irv.
>
Yes. The code below assumes that you do not use datasession - otherwise you should write some code in the datasession so that the second copy of the form do not harm the existing one while trying to execute.
The form is named test but you can change this. Note that SCX filename and Name property of the form itself should be the same.
**************************************************
*-- Form:         test (c:\test\test.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   07/30/02 10:59:02 AM
*
DEFINE CLASS test AS form

	DoCreate = .T.
	Caption = "Test"
	Name = "TEST"
	alreadyloaded = .F. &&Custom property used for preventing other instances from loading

	PROCEDURE Init
		If ThisForm.Alreadyloaded Then
			Return .F.
		EndIF
	ENDPROC


	PROCEDURE Load
		Local lcThisFormName
		lcThisFormName = ThisForm.Name
		If Type(lcThisFormName)=[O] And Type(lcThisFormName+[.BaseClass])=[C] Then
			If Lower(Evaluate(lcThisFormName+[.BaseClass])) == [form] Then
				ThisForm.AlreadyLoaded=.T.
				Return
			EndIf
		EndIf
		Public &lcThisFormName
		&lcThisFormName = ThisForm
		** Load cursors etc.
	ENDPROC


	PROCEDURE Unload
		If ThisForm.AlreadyLoaded Then
			Return
		EndIf
		** Clean-up code
	ENDPROC


ENDDEFINE
*
*-- EndDefine: test
**************************************************
HTH
Zlatin Zlatev,
MCSD (VS6)

Make solutions, not programs!

Previous
Reply
Map
View

Click here to load this message in the networking platform