Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONVERTING VB SYNTAX TO VFP FOR A FUNCTION

Status
Not open for further replies.

LeonelSanchezJr

Programmer
Jan 26, 2001
522
US
I AM TRYING TO CONVERT THE FOLLOWIGN VISUAL BASIC SYNTAX TO VFP6.0:

Declare Function CreateFieldDefFile Lib "p2smon.dll"(lpunk As Object, ByVal filename As String, ByVal bOverWriteExistingFile As Long) As Long


Can anyone help me or tell me the name of a good Visual Foxpro 6.0 Technical Reference book?

Thanks.
 
See DECLARE - DLL in the help file:

DECLARE [cFunctionType] FunctionName IN LibraryName
[AS AliasName]
[cParamType1 [@] ParamName1,
cParamType2 [@] ParamName2, ...]

In the given example:
DECLARE LONG CreateFieldDefFile IN p2smon.dll ;
<something> lpunk, STRING filename, ;
LONG bOverWriteExistingFile

Don't know for sure how to pass an object, as the VFP DECLARE doesn't know OBJECT, but maybe someone else can shed some light?
Diederik Vermeeren
verm1864@exact.nl
 
Hi all my friends,
What are you trying to do, by some how, can fit in the Callback category. Some modern API functions require a function pointer or an object pointer to be passed to them as an argument, so the calling program can respond to some messages from the API, handling some events raised by the API is common use, so the API will raise the event and your program will catch it in the function you passed its address to the API and handle it however you see fit.
Some VB programmers may argue , why going in circles, I will just declare it WITH EVENTS (which we can’t do in VFP). The answer is no you can’t. It is crucial to understand that APIs DLL is not a COM-based.
It means it is not an object and it has no PEMs interface you can communicate with. It is a standard DLL which unlike COM-based DLLs you can’t develop them in VB or VFP. From here the designers of APIs came up with this mechanism CALLBACK. Search MSDN fro Callback for more information.

VB as you know support this mechanism either by ADDRESSOF operator or AS OBJECT. On the other hand, according to Microsoft, unfortunately VFP has no native way to support this mechanism. In the most basic level the reason for that is VFP’s handling of messages is non standard, So if you want to pass a complex structure to API you are in trouble (not to mention pointer to an object), Sorry for carrying these bad news for you.

The good news are, we live in the COM world. So it may worth it to consider developing this component with VB and compile it as a COM server, then instantiate it from VFP
Thanks
Walid Magd
Engwam@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top