Here is a demo which is translated from the bundled CPP version. However there are 2 problems
1. The callback function does not be called
2. No unicode string can be used as the caption
any fix is appretiated
Maybe I should use fbfrog to auto-generated the bi file from the auto-generated C header other than do it by hand;)
Code: Select all
dim as any ptr DLL
dim Application_Instance as function cdecl() as any ptr
dim Application_Initialize as sub cdecl(f as any ptr)
dim Application_CreateForm as function cdecl(f as any ptr, tag as boolean) as any ptr
dim Application_Run as sub cdecl(f as any ptr)
dim Button_Create as function cdecl(f as any ptr) as any ptr
dim Button_SetParent as sub cdecl(i as any ptr, f as any ptr)
dim DShowMessage as sub cdecl(f as any ptr)
dim Button_SetOnClick as sub cdecl(item as any ptr, fun as any ptr)
dim Button_SetCaption as sub cdecl(i as any ptr, f as any ptr)
DLL = dylibload("liblcl.dll")
Application_Instance = dylibsymbol( DLL, "Application_Instance" )
Application_Initialize = dylibsymbol( DLL, "Application_Initialize" )
Application_CreateForm = dylibsymbol( DLL, "Application_CreateForm")
Application_Run = dylibsymbol( DLL, "Application_Run")
DShowMessage = dylibsymbol( DLL, "DShowMessage")
Button_Create = dylibsymbol( DLL, "Button_Create")
Button_SetParent = dylibsymbol( DLL, "Button_SetParent")
Button_SetOnClick = dylibsymbol( DLL, "Button_SetOnClick")
Button_SetCaption = dylibsymbol( DLL, "Button_SetCaption")
sub btnClick(sender as any ptr)
'DShowMessage("Hello world!")
? 11
end sub
var Application = Application_Instance()
Application_Initialize(Application)
var form = Application_CreateForm(Application, False)
var btn = Button_Create(form)
Button_SetParent(btn, form)
Button_SetOnClick(btn, @btnClick)
Button_SetCaption(btn, strptr("hello"))
Application_Run(Application)
DyLibFree( DLL )