https://www.purebasic.fr/english/viewtopic.php?t=43173
I've been testing that code and found a problem: it works fine when using the lib file, but crashes when dynamically loading the dll.
dll code:
Code: Select all
ProcedureDLL addScrollArea(hWnd)
oldGadgetList = UseGadgetList(hWnd)
gadget = ContainerGadget(#PB_Any, 0, 0, 400, 400)
CloseGadgetList()
SetGadgetColor(gadget, #PB_Gadget_BackColor, #Red)
UseGadgetList(oldGadgetList)
EndProcedure
Code: Select all
Import "dll.lib"
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
addScrollArea(a) As "_addScrollArea@4"
CompilerElse
addScrollArea(a)
CompilerEndIf
EndImport
#win = 16 ;Change to 15 or less to remove the crash!
If OpenWindow(#win, 0, 0, 600, 600, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
addScrollArea(WindowID(#win))
Repeat
event=WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Code: Select all
#win = 16 ;Change to 15 or less to remove the crash!
Prototype addScrollArea(a)
Define addScrollArea_.addScrollArea
If OpenLibrary(0, "dll.dll")
addScrollArea_ = GetFunction(0, "addScrollArea")
If OpenWindow(#win, 0, 0, 600, 600, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
If addScrollArea_
addScrollArea_(WindowID(#win))
EndIf
Repeat
event=WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
CloseLibrary(0)
EndIf ; Invalid memory access. (read error at address 1387796518)