Windows in a dynlib / DLL

Just starting out? Need help? Post your questions and find answers here.
Geert
User
User
Posts: 47
Joined: Thu Aug 16, 2012 3:17 pm
Location: Belgium
Contact:

Windows in a dynlib / DLL

Post 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
Visit my website: https://www.basic-apps.com

Home of SoftMaths, ToolsForIcons, Checksums, MoonPhases, ...
Fred
Administrator
Administrator
Posts: 18344
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Windows in a dynlib / DLL

Post by Fred »

Having a seperate event loop in a DLL is not supported in PB.
infratec
Always Here
Always Here
Posts: 7658
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Windows in a dynlib / DLL

Post by infratec »

And ...

my golden rule:

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