Compatibility with UltraMon
Compatibility with UltraMon
Dunno' when, but somewhere starting from 5.xx PureBasic and UltraMon no longer like each other... If I enable UltraMon then the PureBasic IDE will close when I use the 'move to other screen' buttons of UltraMon... It would be nice to get that compatibility back again.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: Compatibility with UltraMon
I don't think PureBasic has ever had compatibility with other third-party
apps built-in. Whatever was working before was probably co-incidence.
Or maybe this post by GoodNPlenty will work for you:
http://www.purebasic.fr/english/viewtop ... =0#p339508
apps built-in. Whatever was working before was probably co-incidence.
Or maybe this post by GoodNPlenty will work for you:
http://www.purebasic.fr/english/viewtop ... =0#p339508
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- Enthusiast
- Posts: 112
- Joined: Wed May 13, 2009 8:38 am
- Location: Arizona, USA
Re: Compatibility with UltraMon
This is how I set mine up and its working great with 5.20 beta 17blueznl wrote:Dunno' when, but somewhere starting from 5.xx PureBasic and UltraMon no longer like each other... If I enable UltraMon then the PureBasic IDE will close when I use the 'move to other screen' buttons of UltraMon... It would be nice to get that compatibility back again.

Click Configure Settings

I do this step with PureBasic running, if not you will have to browse to the PureBasic.exe
If you use both x86 and x64 IDE's you will have to setup both.
I just use the x64 IDE and setup the different compilers in preferences.

Select 'alternate method to add window buttons' then click finish.
Close and restart the PureBasic IDE and it should work great.
Re: Compatibility with UltraMon
I use the same. Unfortunately you have to do it for every program written with PB.GoodNPlenty wrote:Select 'alternate method to add window buttons' then click finish.
Close and restart the PureBasic IDE and it should work great.
Pressing the minimize window button always quits the program here.
Re: Compatibility with UltraMon
http://www.purebasic.fr/english/viewtop ... =0#p339508
Note: #WM_CLOSE = #PB_Event_CloseWindow on Windows.
Looks like Purebasic forwards this #WM_CLOSE of UltraMon to us. So I wrote a workaround to forward #WM_CLOSE only if it is coming from
our own PureBasic windows.
The problem I had:
PureBasic Windows always get closed on minimize when using the window flags #PB_Window_MinimizeGadget and #PB_Window_SizeGadget together.
Without the flag #PB_Window_SizeGadget it does not happen!
Simple example:
If I press the minimize window button (or window system menu 'minimize'), the program ends, because a #PB_Event_CloseWindow (#WM_CLOSE) message arrived.
Here is my workaround:
The workaround only forwards #WM_CLOSE / #PB_Event_CloseWindow if it is coming from a PureBasic window callback.
Tested with PB5.11 and PB5.20b17 (each x86 and x64), running UltraMon 3.2.2
Thanks GoodNPlenty, that helped me finding a workaround!GoodNPlenty wrote:Here's what happens: when you minimize PureBasic, UltraMon removes the window buttons by posting WM_CLOSE to the button window. By default UltraMon creates the window for the buttons in the application process, meaning that the message loop of the application gets the posted message. Usually a message loop will forward all messages to the associated window procedure, but if the application doesn't do this and instead processes the WM_CLOSE message directly, this could cause the behavior you're seeing.
Note: #WM_CLOSE = #PB_Event_CloseWindow on Windows.
Looks like Purebasic forwards this #WM_CLOSE of UltraMon to us. So I wrote a workaround to forward #WM_CLOSE only if it is coming from
our own PureBasic windows.
The problem I had:
PureBasic Windows always get closed on minimize when using the window flags #PB_Window_MinimizeGadget and #PB_Window_SizeGadget together.
Without the flag #PB_Window_SizeGadget it does not happen!
Simple example:
Code: Select all
If OpenWindow(0, 0, 0, 400, 200, "PureBasic Window", #PB_Window_SystemMenu |
#PB_Window_ScreenCentered |
#PB_Window_MinimizeGadget |
#PB_Window_MaximizeGadget |
#PB_Window_SizeGadget )
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
EndIf
Here is my workaround:
Code: Select all
;------------------------------------------------------------------------------------
;
; Workaround for compatibility problem with UltraMon and Purebasic programs
;
;------------------------------------------------------------------------------------
Global NewMap WM_CLOSE_MAP.i()
Procedure WindowCallback(hWnd, msg, wParam, lParam)
If msg = #WM_CLOSE
WM_CLOSE_MAP(Str(hWnd))=1 ; set WM_CLOSE_MAP for this PB window
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
SetWindowCallback( @WindowCallback() )
Procedure.i New_WaitWindowEvent(timeout)
;
; block #PB_Event_CloseWindow if the window has not received #WM_CLOSE before
;
If timeout = -1
event = WaitWindowEvent()
Else
event = WaitWindowEvent(timeout)
EndIf
If event = #PB_Event_CloseWindow And WM_CLOSE_MAP( Str(WindowID(EventWindow()) ) ) = 0
event = 0
EndIf
ProcedureReturn event
EndProcedure
Procedure.i New_WindowEvent()
;
; block #PB_Event_CloseWindow if the window has not received #WM_CLOSE before
;
event = WindowEvent()
If event = #PB_Event_CloseWindow And WM_CLOSE_MAP( Str(WindowID(EventWindow()) ) ) = 0
event = 0
EndIf
ProcedureReturn event
EndProcedure
Procedure.i New_OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags, ParentWindowID)
;
; clear WM_CLOSE_MAP for the new window
;
win = OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags, ParentWindowID)
If win
If window = #PB_Any
WM_CLOSE_MAP(Str(WindowID( win )))=0
Else
WM_CLOSE_MAP(Str(WindowID(window)))=0
EndIf
EndIf
ProcedureReturn win
EndProcedure
Macro WaitWindowEvent(timeout=-1)
New_WaitWindowEvent(timeout)
EndMacro
Macro WindowEvent()
New_WindowEvent()
EndMacro
Macro OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title, Flags= #PB_Window_SystemMenu, ParentWindowID=0)
New_OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title, Flags, ParentWindowID)
EndMacro
;------------------------------------------------------------------------------------
;
; End UltraMon workaround
;
;------------------------------------------------------------------------------------
If OpenWindow(0, 0, 0, 400, 200, "PureBasic Window", #PB_Window_SystemMenu |
#PB_Window_ScreenCentered |
#PB_Window_MinimizeGadget |
#PB_Window_MaximizeGadget |
#PB_Window_SizeGadget )
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
EndIf
Tested with PB5.11 and PB5.20b17 (each x86 and x64), running UltraMon 3.2.2
Can you test the workaround, please? For me it happened only on minimize. With 'move to other screen' I didn't have the problem here.blueznl wrote:Dunno' when, but somewhere starting from 5.xx PureBasic and UltraMon no longer like each other... If I enable UltraMon then the PureBasic IDE will close when I use the 'move to other screen' buttons of UltraMon... It would be nice to get that compatibility back again.
Re: Compatibility with UltraMon
PureBasic could probably fix and avoid such issues if #PB_Event_* messages would not conflict with WinAPI messages.
WinAPI messages can be used in callbacks, so #PB_Event_* messages should be in a range that does not conflict with WinAPI messages.
WinAPI messages can be used in callbacks, so #PB_Event_* messages should be in a range that does not conflict with WinAPI messages.
Code: Select all
;------------------------------------------------------------------------------------
;
; Workaround 2 for compatibility problem with UltraMon and Purebasic programs
;
;------------------------------------------------------------------------------------
#PB_Event_CloseWindow_NEW = #PB_Event_FirstCustomValue
Procedure WindowCallback(hWnd, msg, wParam, lParam)
If msg = #WM_CLOSE
PostEvent(#PB_Event_CloseWindow_NEW,EventWindow(),0)
ProcedureReturn 0
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
SetWindowCallback( @WindowCallback() )
;------------------------------------------------------------------------------------
;
; End UltraMon workaround 2
;
;------------------------------------------------------------------------------------
If OpenWindow(0, 0, 0, 400, 200, "PureBasic Window", #PB_Window_SystemMenu |
#PB_Window_ScreenCentered |
#PB_Window_MinimizeGadget |
#PB_Window_MaximizeGadget |
#PB_Window_SizeGadget )
While WaitWindowEvent() <> #PB_Event_CloseWindow_NEW : Wend
EndIf