Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to prevent run the Form twice?
Message
De
14/08/2013 09:38:06
 
 
À
14/08/2013 04:37:35
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01580450
Message ID:
01580457
Vues:
64
>Hi,
>I want to prevent user to run or open the FORM twice,
>how to check the specific form are opened or active ?
>Please advise.
>Derek Yim

you can check the _screen.forms collection as in the sample program below
* checkFormNotLaunched.prg
* Launch a form if not already launched
local form1, form2

clear
? Datetime(), 'start'

form1 = CreateObject('formTest', 'form1')
activate screen
? Datetime(), 'form1', m.form1

form2 = CreateObject('formTest', 'form2')
activate screen
? Datetime(), 'form2', m.form2

MessageBox('End test?')

* ===========================
define class formTest as form

	autocenter = .T.

	procedure init(caption)

		this.Caption = m.caption

		local llSCX, lcSCX, oForm as Form

		llSCX = Empty(m.this.ClassLibrary)
		lcSCX = Sys(1271, m.this)
		for each oForm in _Screen.Forms foxobject
			if not m.oForm = m.this
				if Iif(m.llSCX;
						, Sys(1271, m.oForm) == m.lcSCX;
						, m.oForm.Class == this.class and m.oForm.ClassLibrary == this.ClassLibrary;
						)
					m.oForm.Init(m.caption) && don't forget to init existing form to whatever parameters you need
					m.oForm.Show
					return .F.
				endif
			endif
		endfor

		* Some more code ...
	endproc
enddefine
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform