Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Register ocx from within vfp
Message
De
19/01/2007 18:49:26
 
 
À
19/01/2007 18:28:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01187233
Message ID:
01187255
Vues:
27
I wrote the following. Syntax to call (with example):
llOCX_OK = RegisterOCX("MSComCtl","MSComctlLib.TreeCtrl")
The first line is the
************************************************************************************************
*
*  Routine for checking the registration of OCX controls
*
FUNCTION RegisterOCX
LPARAMETERS  pcControlName,pcControlClass
LOCAL loOLEForm, llRtnCode, lcOCXFile, lcOCXTgt, llFileOK, lcSrcPath, lcOCXSrc, lcTLBSrc, lcTLBTgt, lcUserMsg
PUBLIC glOCXError
ON ERROR STORE .T. to glOCXError
glOCXError = .F.
loOLEForm = CREATEOBJECT('Form')
loOLEForm.AddObject('OCXTest','OLEControl',pcControlClass)
IF glOCXError
	lcOCXFile = FORCEEXT(pcControlName,".ocx")
	lcOCXTgt  = ADDBS(fGetSystemDir()) + lcOCXFile
	IF FILE(lcOCXTgt)
		DECLARE INTEGER DllRegisterServer IN (lcOCXFile) AS _DllRegisterServer
		IF _DllRegisterServer() != 0
			lcUserMsg = "Unable to register the OCX control" + pcControlName + "
			=MSGBOX(lcUserMsg,"System Message",16,"ERROR")
			llRtnCode = .F.
		ELSE
			llRtnCode = .T.
		ENDIF
	ENDIF
ELSE
	llRtnCode = .T.
ENDIF
loOLEForm.release()
RELEASE glOCXError
RETURN llRtnCode
ENDFUNC



FUNCTION fGetSystemDir
LOCAL lcDir, lnHossz
DECLARE INTEGER GetSystemDirectory IN WIN32API STRING @lcDir, INTEGER lnMaxHossz
lcDir = SPACE(256)
lnHossz = GetSystemDirectory(@lcDir,255)
IF lnHossz > 0
	RETURN LEFT(lcDir,lnHossz)
ELSE
	RETURN ""
ENDIF
ENDFUNC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform