What most visitors search for before coming to this page.
I'm not sure if anyone is going to be interested in this, it's just a little side project I've been meaning to mess around with for awhile. For now this is nothing more than a translation of the very incomplete C interface. It's basically just enough to show a window, a button, and take an OnClick event. The long shot idea is to build a wrapper over this to be as close to classic VB as possible and that would give us a very nice portable way to target multiple platforms and native widget sets (native Win32, GTK+, QT, Carbon, Cocoa, and custom drawn options) all with the same code. Again, this is nothing more than a start, and the LCL is a massive library and designing a good OO wrapper for it would be a huge undertaking. But I figured I would put it up here in case anyone was interested in hacking on it further.
Note that this is pretty much a direct translation of the C header experiment, which involves breaking down a very complex Object Pascal library in to something accessible in a lower level procedural style. As such, the code is much more complex than your run of the mill binding to a C library and it contains a few typedefs to Pascal specific types and some macros to retain the feel and structure of the library.
For the purposes I imagine something like this being used those constructs could be abandoned and a format more familiar to Visual Basic programmers could be used. Due to how close knit VB and Windows are with the use of ActiveX components and all that, I highly doubt it could be fashioned in to a means of compiling straight VB project source, I could provide a path for migration and a familiar language for new software.
As of right now though, that is but a pipe dream. The Lazarus project containing the necessary exports and a copy of the original C bindings can be pulled from here.
Code: 'clazhello.bas 'LCL EXPORTS LIBRARY TEST #include 'vcl.bi' Dim shared MyForm as TFormB Dim shared MyButton as TButtonB Dim shared MyLabel as TLabelB 'callback for close button FASTCALLTNOTIFYEVENTSTART(MyButtonOnClick) TCustomFormClose(MyForm) END SUB 'FASTCALL macros in controls.bi 'APPLICATION ENTRY POINT ApplicationInitialize ApplicationCreateForm (@MyForm) TControlSetTop(MyForm, 50) TControlSetLeft(MyForm, 50) TControlSetHeight(MyForm, 200) TControlSetWidth(MyForm, 200) TControlSetCaption(MyForm, 'Lazarus in FB!!' ) MyButton = TButtonCreate(MyForm) TWinControlSetParent(MyButton, MyForm) TControlSetTop(MyButton, 150) TControlSetLeft(MyButton, 50) TControlSetWidth(MyButton, 100) TControlSetOnClick(MyButton, @MyButtonOnClick) TControlSetCaption(MyButton, 'Close Button') MyLabel = TLabelCreate(MyForm) TWinControlSetParent(MyLabel, MyForm) TControlSetTop(MyLabel, 50) TControlSetLeft(MyLabel, 60) TControlSetCaption(MyLabel, 'It works!!!!' ) 'Enter main loop ApplicationRun I have not tested or even tried to build this on Windows yet, it's not a platform I know too much about, I'm not sure if there is anything that needs to be modified in the exports, but it should be just like linking to any other DLL. On linux it builds with something like this, I had the.so in the same directory, you may need to inform the linker of it's location if your system is different.