> Thanks for the info, what a shame PB's gadget commands can't take a
> gadget address rather than an ID, maybe it should be a feature request.
I think this will come, as soon as the Gadget Numbers are made optional.
I've experimented a bit, and found the following little trick, it let's you
still use PB's commands from within the DLL, to access the Gadgets.
First comes the DLL code:
NewPointer = Pointer
!MOV dword EAX, [v_NewPointer]
!MOV dword [_PB_Gadget_ObjectsArea], EAX
SetGadgetText(Gadget, "This is set from the DLL!")
And here the Main app:
!MOV dword EAX, [_PB_Gadget_ObjectsArea]
!MOV dword [v_MainPointer], EAX
CallFunction(Library, "SetGadgetPointer", MainPointer)
#Lib = 1
#TextGadget = 1
If OpenLibrary(#Lib, "purebasic.dll")
If OpenWindow(0, 0, 0, 300, 300, #PB_Window_SystemMenu|#PB_Window_Screencentered, "testing...")
TextGadget(#TextGadget, 10, 10, 280, 20, "This text is from the main prog!")
CallFunction(#Lib, "Test", #TextGadget)
Until WaitWindowEvent() = #PB_EventCloseWindow
Some notes about this:
Do not Create/Free any Gadgets fro inside the DLL, this should not work
correctly (lead to a crash). Instead, create all Gadgets from the main
App, and only modify them from the DLL!
The UpdateGadgetPointer() function must be called after each time you
created/freed Gadgets, as then this pointer may change internally. So
if you create new Gadgets somewhere, make sure, there is a
UpdateGadgetPointer() somewhere before the next call to the DLL.
That's it, happy coding...