Page 1 of 1

Windows in a dynlib / DLL

Posted: Thu Jan 31, 2013 6:58 pm
by Geert
The code below works with PB 4.61 (x86, MacOSX) and with PB 4.61/5.10b5 (x86, Windows).

But it behaves strangely with PB 5.10b5 (x86, MacOSX).

The button (in the main window) disappears when clicked.
After the second Window is displayed, both the windows can't be closed anymore...

Changing the buttongadget number to 1, prevents the button from disappearing, but the windows are still freezing...

Code: Select all

;Compile into a threadsafe dynlib / DLL "TestWindow.so" "TestWindow.dll"

ProcedureDLL TestWindow()
 If OpenWindow(0, #PB_Ignore, #PB_Ignore, 200, 100, "DLL Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
  
  ButtonGadget(0,50,50,100,22,"OK")
  
  Repeat
   Event = WaitWindowEvent()
   
   If Event=#PB_Event_Gadget
    Break 
   EndIf
  Until Event = #PB_Event_CloseWindow
  
  CloseWindow(0)
  
 EndIf
EndProcedure

Code: Select all

;Compile into a threadsafe executable

CompilerIf #PB_Compiler_OS=#PB_OS_Windows
 #DLLExt$=".dll"
CompilerElse
 #DLLExt$=".so"
CompilerEndIf

If OpenLibrary(0,#PB_Compiler_FilePath+"TestWindow"+#DLLExt$)

 If OpenWindow(0, #PB_Ignore, #PB_Ignore, 200, 200, "Main Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
  
  ButtonGadget(0,25,25,150,22,"Test DLL Window")
  
  Repeat
   
   Event = WaitWindowEvent()
   
   If Event = #PB_Event_Gadget
    CallFunction(0,"TestWindow")
   EndIf 
   
  Until Event = #PB_Event_CloseWindow
 
 EndIf
 
EndIf

Re: Windows in a dynlib / DLL

Posted: Sun Feb 18, 2024 9:46 am
by Fred
Having a seperate event loop in a DLL is not supported in PB.

Re: Windows in a dynlib / DLL

Posted: Sun Feb 18, 2024 10:24 am
by infratec
And ...

my golden rule:

One event loop in one programm.
And as Yoda says: no more no less