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!

FoxPro and APIs

Status
Not open for further replies.

Walid

Programmer
May 18, 2000
382
US
In an effort to bridge gaping VFP and VB, specially nowadays it sounds like we (VFP programmers) will need to use VB as a COM builder to be able to support some functionalities VFP doesn’t support natively. I will start this thread to explain one of the major deference between the two tools, I don’t know if what I am doing ( Taking a thread and post it in this aria) is consistent with the site policy or not ). If not sorry for that (I'm new to the forum)please feel free to correct me.

On Feb 1,2001 Leonelsanchezjr asked

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

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
 
Walid, this is not new theme. Go to Universal Thread ad you will find a lot of articles about call backs.

It is also easy to make a simple activeX control for VFP that will serve its event as call back function and its property will contain an address for use as address of call back in API functions.

The problem of VFP is that its functions have no address at all, thay could be located and re-allocated in the phisical memory. In additional, they're just a interpreter codes, so special event launching code required to organize call backs.

Anyway, some way MS made a support of making code for ActiveX controls events. I guess MS can do this also for callbacks. I put this note into VFP7 wish list.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top