This problem with API declarations will be (hopefully) solved in the next version of the class, I just stole an idea used in GDIPlusX.
This is what I do:
I have a prg with all the API declarations, this PRG is called in the init of each class. The first few lines of this prg are:
#Include ctl32.h
If Not Juststem(Sys(16)) $ Set("Procedure") Then
Set Procedure To Sys(16) Additive
Endif
Return
After that, ALL the API declares are included, and each one of them is a VFP function. The name of the VFP function and the alias used in the declare statement is the same, for example:
********************************************************************************
Function apiGetForegroundWindow()
********************************************************************************
Declare Integer GetForegroundWindow In win32api As apiGetForegroundWindow
Return apiGetForegroundWindow()
Endfunc
Now, the first time apiGetForegroundWindow is called somewhere in code, the VFP function will be executed, this will declare the API function. What happens then is that a declared API call takes precedence over a VFP function with the same name, so the function just calls itself again, with the passed parameters, if any, and since the API function is already declared, the API function is called instead of the VFP function.
Another benefit of this is that if you have a CLEAR DLLS somewhere in your code, then the VFP function will be called then, that will redeclare the API function.... etc.
Another example with parameters:
********************************************************************************
Function apiGetClientRect(m.nHWnd, m.lcRect)
********************************************************************************
Declare Integer GetClientRect In win32api As apiGetClientRect ;
Integer nHWnd,;
String @lcRect
Return apiGetClientRect(m.nHWnd, @m.lcRect)
Endfunc
Carlos
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only