There is nothing wrong to stay with old PB versions, I also have very old tools, I didn't touch for ages and just am too lazy to get them pushed to the latest updates.
But as a matter of fact, none of my hundreds of tools, no matter how old, "break" when minimizing.
Which means, the reason for the effect is not PB per se, but something in your code.
But without seeing the effect with an example code, no one will be able to help you.
My crystal ball tells me you might make use of SetGadgetColor().
BarryG is right, try to shrink it down to a small example showing the effect, only then you'll receive useful help.
[SOLVED-mostly] minimize+Restore Loses all my gadgets
Re: minimize+Restore Loses all my gadgets
Hi Randy
I have a feeling about your use of #WM_SIZE
Next is my last shoot
Use one of them in your window callback
I wish you luck
I have a feeling about your use of #WM_SIZE
Next is my last shoot
Use one of them in your window callback
I wish you luck
Code: Select all
Case #WM_SYSCOMMAND
Select wParam
Case #SC_MAXIMIZE
Debug WindowX(?)
Debug WindowWidth(?)
Case #SC_RESTORE
ShowWindow_(WindowID(?),#SW_HIDE)
ResizeWindow(?,0,0,400,400)
ShowWindow_(WindowID(?),#SW_SHOW)
EndSelect
Case #WM_SIZE
Select wParam
Case #SIZE_MINIMIZED
Debug "Window was minimized"
Case #SIZE_RESTORED
; ShowWindow_(WindowID(0),#SW_HIDE)
; ResizeWindow(0,0,0,400,400)
; ShowWindow_(WindowID(0),#SW_SHOW)
;Debug "Window was restored"
Case #SIZE_MAXIMIZED
;Debug "Window was maximized"
EndSelect
Egypt my love
-
Randy Walker
- Addict

- Posts: 1266
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
- Contact:
Re: minimize+Restore Loses all my gadgets
I tried these two APIs first and both had a problem with restore:
Last but not least I tried the native PB command which I didn't know existed until someone pointed it out to me and it seems to have cured the problematic gadget redraw issue for the most part:
Code: Select all
;ShowWindow_(HWND0,#SW_MINIMIZE)
;ShowWindow_(HWND0,#SW_SHOWMINIMIZED)
Code: Select all
SetWindowState(#Window_0,#PB_Window_Minimize)
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
Re: [SOLVED-mostly] minimize+Restore Loses all my gadgets
It goes to 99.9% even without taking Windows API ...
Code: Select all
;-TOP
#ProgramTitle = "Main Window"
#ProgramVersion = "v1.01.2"
Enumeration Windows
#Main
EndEnumeration
Enumeration MenuBar
#MainMenu
EndEnumeration
Enumeration MenuItems
#MainMenuAbout
#MainMenuExit
EndEnumeration
Enumeration Gadgets
#MainEdit
#MainButton1
#MainButton2
#MainButton3
EndEnumeration
Enumeration StatusBar
#MainStatusBar
EndEnumeration
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
; Resize gadgets
ResizeGadget(#MainEdit, 5, 5, dx - 10, dy - 45)
ResizeGadget(#MainButton1, 10, dy - 35, 120, 30)
ResizeGadget(#MainButton2, 140, dy - 35, 120, 30)
ResizeGadget(#MainButton3, 270, dy - 35, 120, 30)
EndProcedure
Procedure Main()
Protected dx, dy
#MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, #ProgramTitle , #MainStyle)
; Menu
CreateMenu(#MainMenu, WindowID(#Main))
MenuTitle("&File")
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
MenuItem(#PB_Menu_About, "")
CompilerElse
MenuItem(#MainMenuAbout, "About")
CompilerEndIf
; Menu File Items
CompilerIf Not #PB_Compiler_OS = #PB_OS_MacOS
MenuBar()
MenuItem(#MainMenuExit, "E&xit")
CompilerEndIf
; StatusBar
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
; Gadgets
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
EditorGadget(#MainEdit, 5, 5, dx -10, dy - 45)
ButtonGadget(#MainButton1, 10, dy - 35, 120, 30, "Minimize")
ButtonGadget(#MainButton2, 140, dy - 35, 120, 30, "Maximize")
ButtonGadget(#MainButton3, 270, dy - 35, 120, 30, "Normal")
; Bind Events
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
; Event Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Main
Break
EndSelect
Case #PB_Event_Menu
Select EventMenu()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Case #PB_Menu_About
PostEvent(#PB_Event_Menu, #Main, #MainMenuAbout)
Case #PB_Menu_Preferences
Case #PB_Menu_Quit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
CompilerEndIf
Case #MainMenuAbout
MessageRequester("About", #ProgramTitle + #LF$ + #ProgramVersion, #PB_MessageRequester_Info)
Case #MainMenuExit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #MainEdit
Select EventType()
Case #PB_EventType_Change
;
EndSelect
Case #MainButton1
SetWindowState(#main, #PB_Window_Minimize)
Case #MainButton2
SetWindowState(#Main, #PB_Window_Maximize)
Case #MainButton3
SetWindowState(#Main, #PB_Window_Normal)
EndSelect
EndSelect
ForEver
EndIf
EndProcedure : Main()
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
Re: minimize+Restore Loses all my gadgets
Sorry, but ChatGPT is just telling you 100% bullsh*t there. It's nothing to do with Win32 API and DWM handle paint deferrals.ChatGPT wrote: Thu Oct 30, 2025 2:03 amNow this behavior totally makes sense — several versions of PureBasic (especially around 5.3–5.4) had exactly this issue on Windows 10 and later:
after minimizing and restoring from the taskbar, the window sometimes comes back completely blank until it’s moved, resized, or another window overlaps it.
It’s not you — it’s a combination of how PureBasic wraps the Win32 API and how newer versions of DWM handle paint deferrals.
Please show us a standalone snippet that proves the problem.
-
Randy Walker
- Addict

- Posts: 1266
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
- Contact:
Re: [SOLVED-mostly] minimize+Restore Loses all my gadgets
Not sure what you what you were trying to show me here.
I was getting extremely bizarre behavior on my main window, occurring randomly if I used my custom minimize button to minimize, following that up with opening and closing another app and the restore my main window again, No matter Hoe I restored it, Gadgets were not being redrawn. It basically just came up a black window not normal title bar.
Yet no redraw issue at all if I used the native Windows _ minimize button up in the title bar.
Don't know if it should matter or not, my main window has 99 gadgets, not including a couple container gadgets.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.
Randy
I *never* claimed to be a programmer.
Nothing is faster, more stable, or easier to maintain than code that doesn’t exist.

