How do i create a user-defined type in foxpro 2.6? The problem stems from me trying to call an api function that requires a parameter of a custom type.
In vb6 i simply say:
Private Type test
var1 as string * 10
var2 as integer
var3 as boolean
End Type
You are limited to the predefined types in Foxpro, but if you don't declare their type before using them , they will default to a logical data type with .F. as the value.
To declare them before using them , just assign them a value:
STORE '' TO charType
STORE 0 TO numType
STORE .F. TO boolType
"The problem stems from me trying to call an api function that requires a parameter of a custom type."
It would seem that your needs would be defined on the variety of 'types' that are recognized by the API, not by Foxpro.
I'd suggest that you do some investigation into the requirements and allowed options of the API and then you can set up your FP users with whatever is needed through code.
To be more specific, i was trying to add a system tray icon (to the system tray obviously):
In vb6 i simply say:
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
szInfo As String * 256
End Type
Private Declare Sub Shell_NotifyIconA Lib "shell32" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA)
..."pnid" is a custom type, this is where i am slipping up.
i know how to call a function from a 32bit library... do i simply just send an array, like the one DSummZZZ (dave summer) suggests?
The normal way to build structures in VFP you can pass to some API function is to stuff them together in memory by using a string with the structure size as a buffer and converting the basic subtypes to strings, Take a look at
You were correct, structures (or as i called them User-Defined types) can be built by simply concatenating the values (aka stuffing them together in memory.
I would also like to thank microsoft.public.fox.programmer.exchange's Andrew Howell for his explanation of Structures, and his correction of my above code:
Well I'll be d@mned. I didn't know there was a thunker out there that actually worked for this sort of thing.
A star for you for teaching an old dog a new trick.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.