Well, I've brushed off the dust, and now... well, it simply doesn't work.
Whether it's a change in PB or GTK I don't know, and I can't go back due to earlier versions of the IDE causing a segmentation fault in Ubuntu 9.10.
The idea behind it was the main form is created and then the WindowID is then passed in to the dll which would then use that WindowID to assign it's gadgets to.
Events were then passed through from the main exe into the dll to be processed, and then when the close is signalled from the dll, it would then release the gadgets.
Very cludgy and hacky.
I tried it in windows and it... mostly works, it just throws up an invalid memory access error when trying to close the dll down.
In Linux, it creates the gadgets (I get gadget id's) but I get warnings from GTK and no gadgets appear.
Here is the windows version. For the Linux version remember to change the dll to "app1.so"
main.pbCode: Select all
EnableExplicit
;- Window Constants
;
Enumeration
#Window_Main
EndEnumeration
;- Gadget Constants
;
Enumeration
#UserArea
EndEnumeration
Procedure OpenMainWindow()
If OpenWindow(#Window_Main, 0, 0, 640, 480, "Central", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
HyperLinkGadget(1, 20, 20, 80, 30, "Hello World", RGB(0, 0, 255))
EndIf
EndProcedure
Procedure Main()
OpenMainWindow()
Protected dllLoaded.b = #False
Protected dll.i
Protected Event
Protected WindowID
Protected GadgetID
Protected EventType
Repeat ; Start of the event loop
Event = WaitWindowEvent()
WindowID = EventWindow()
GadgetID = EventGadget()
EventType = EventType()
Select Event
Case #PB_Event_Gadget
If GadgetID > 0
If Not dllLoaded
dll = OpenLibrary(#PB_Any, "app1.dll")
CallFunction(dll, "HelloWorld_New", WindowID(#Window_Main))
dllLoaded = #True
EndIf
EndIf
If dllLoaded
Protected rv.l = CallFunction(dll, "HelloWorld", Event, WindowID, GadgetID, EventType)
If Not rv
CallFunction(dll, "HelloWorld_Release")
CloseLibrary(dll)
dllLoaded = #False
EndIf
EndIf
Default
EndSelect
Until Event = #PB_Event_CloseWindow
EndProcedure
Main()
End
app1.pbCode: Select all
; app1.dll
Global HelloWorld_btnHelloWorld
Global HelloWorld_btnQuit
ProcedureDLL.l HelloWorld_New(pGadgetArea)
UseGadgetList(pGadgetArea)
HelloWorld_btnHelloWorld = ButtonGadget(#PB_Any, 170, 60, 80, 40, "Hello World")
HelloWorld_btnQuit = ButtonGadget(#PB_Any, 120, 10, 80, 30, "Quit")
EndProcedure
ProcedureDLL HelloWorld_Release()
FreeGadget(HelloWorld_btnHelloWorld)
FreeGadget(HelloWorld_btnQuit)
EndProcedure
ProcedureDLL.b HelloWorld(Event, WindowID, GadgetID, EventType)
If Event = #PB_Event_Gadget
Select GadgetID
Case HelloWorld_btnHelloWorld
MessageRequester("Test", "Hello World", #PB_MessageRequester_Ok)
Case HelloWorld_btnQuit
ProcedureReturn #False
EndSelect
EndIf
ProcedureReturn #True
EndProcedure