Page 1 of 3
minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 4:03 am
by Randy Walker

I don't think it is me this time. I put a minimize button on the main window of my app. When I minimize with using that button and then restore, all my gadgets are gone. If I minimize and restore using the icon in the taskbar 3 times after the gadgets vanish, the window redraws properly and all the gadgets are back. I don't see this behavior if I minimize using normal conventions so it seems to be some issue related to the ShowWindow_(HWND0,#SW_MINIMIZE) command I'm using. Thought I would try a postmessage or sendmessage equivalent, either cannot figure out the right syntax or it's just not working. Very strange and really annoying. I even tried capturing the #WM_RESTORE so I could un-hide all the gadgets but they cannot be un-hidden. Probably just me. Anyone ever seen anything like that?
Code: Select all
SendMessage_(HWND0,#WM_SHOWWINDOW, #SIZE_MINIMIZED, 0)
PostMessage_(HWND0,#WM_SHOWWINDOW, #SIZE_MINIMIZED, 0)
Don't do anything.
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 5:11 am
by RASHAD
Hi
How about ShowWindow_()

Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 5:45 am
by Randy Walker
RASHAD wrote: Wed Oct 29, 2025 5:11 am
Hi
How about ShowWindow_()
Yes as I commented above, that is the exact command I was using. Just now I changed that to this and seems to be more stable:
ShowWindow_(HWND0,#SW_SHOWMINIMIZED) << instead of #SW_MINIMIZE
It still minimizes but not going wonky on restore as before. Hopefully this is the fix. Will update here in a day or two after more testing...
Re: minimize+Restore intermittently Loses all my gadgets
Posted: Wed Oct 29, 2025 6:00 am
by Randy Walker
Spoke too soon... #SW_SHOWMINIMIZED did NOT fix it, Still going blank intermittently on restore.
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 7:03 am
by RASHAD
Try
Code: Select all
ShowWindow_(WindowID(?),#SW_RESTORE )
InvalidateRect_(WindowID(?),0,1)
OR
ShowWindow_(WindowID(?),#SW_RESTORE )
UpdateWindow_(WindowID(?))
OR
SendMessage_(WindowID(?),#WM_SYSCOMMAND,#SC_RESTORE,1)
PostMessage_(GadgetID(0), #WM_LBUTTONDOWN, 0, 0)
PostMessage_(GadgetID(0), #WM_LBUTTONUP, 0, 0)
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 7:53 am
by Randy Walker
RASHAD wrote: Wed Oct 29, 2025 7:03 am
Try
Code: Select all
ShowWindow_(WindowID(?),#SW_RESTORE )
InvalidateRect_(WindowID(?),0,1)
OR
ShowWindow_(WindowID(?),#SW_RESTORE )
UpdateWindow_(WindowID(?))
OR
SendMessage_(WindowID(?),#WM_SYSCOMMAND,#SC_RESTORE,1)
PostMessage_(GadgetID(0), #WM_LBUTTONDOWN, 0, 0)
PostMessage_(GadgetID(0), #WM_LBUTTONUP, 0, 0)
I'm not using any code to restore the window. I'm just clicking the icon in the taskbar to do restore. Or using relaunch which tells the current process to restore and take foreground and then the new process terminates. I also tried catching the WM_RESTORE so I could tell it to InvalidateRect_ the window but had no affect.
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 8:15 am
by RASHAD
If you are using SetWindowCallback(@ProcedureName() [, #Window [, Mode]])
Add the next
Code: Select all
Case #WM_SYSCOMMAND
Select wParam
Case #SC_RESTORE
PostMessage_(WindowID(?), #WM_LBUTTONDOWN, 0, 0)
PostMessage_(WindowID(?), #WM_LBUTTONUP, 0, 0)
EndSelect
If your gadgets inside a Canvas Container
Code: Select all
Case #WM_SYSCOMMAND
Select wParam
Case #SC_RESTORE
PostMessage_(GadgetID(?), #WM_LBUTTONDOWN, 0, 0)
PostMessage_(GadgetID(?), #WM_LBUTTONUP, 0, 0)
EndSelect
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 8:47 am
by BarryG
Why are you using API calls instead of the SetWindowState() command?
And try to post a standalone snippet of code that shows the problem.
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 9:46 am
by mk-soft
BarryG wrote: Wed Oct 29, 2025 8:47 am
Why are you using API calls instead of the SetWindowState() command?
And try to post a standalone snippet of code that shows the problem.
Right

Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 8:25 pm
by Randy Walker
BarryG wrote: Wed Oct 29, 2025 8:47 am
Why are you using API calls instead of the SetWindowState() command?
Such a good question! Primarily because I didn't know that was an available option.
Now that I know and have tried it, my new command line to replace the API is:
SetWindowState(#Window_0,#PB_Window_Minimize)
That does indeed minimize the window. Now I just have to wait and see if that is going to make a difference. (Problem being intermittent as it is.) I also added code RASHAD suggested.
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 8:29 pm
by Randy Walker
RASHAD wrote: Wed Oct 29, 2025 8:15 am
If you are using SetWindowCallback(@ProcedureName() [, #Window [, Mode]])
Add the next
Code: Select all
Case #WM_SYSCOMMAND
Select wParam
Case #SC_RESTORE
PostMessage_(WindowID(?), #WM_LBUTTONDOWN, 0, 0)
PostMessage_(WindowID(?), #WM_LBUTTONUP, 0, 0)
EndSelect
Not using Canvas Container but I did follow the above suggestion, Now just have to wait to see if any improvement. (Problem being intermittent as it is.) I also substituted code suggested by BarryG to replace the minimize API.
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 8:56 pm
by Randy Walker
Nope Afraid the issue still exists, so I'll just have to have my minimize button position the mouse over the Window titlebar minimize button and send left click, hoping for the best.
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 9:36 pm
by Randy Walker
How goofy is this for a workaround? -- If it even solves the problem. It does minimize the window, so time will tell.
Code: Select all
Procedure MinimizeWin0()
GetWindowRect_(TOPwh,rw)
wpx = rw\right -100
wpy = rw\top+15
SetCursorPos_(wpx,wpy) ;mouse nicely positioned over the _ minimize button in the titlebar.
mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
EndProcedure
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 9:48 pm
by Randy Walker
Nope, even goingto that extreme had no affect. Window can still come up blank.
I did notice something though, I create the window invisible and hidewindow(#HWND0,0) after after launch when everything is loaded and initialized. The window shows blank for a few seconds while all that initialization is taking place, and then all the gadgets suddenly appear. So maybe hide unhide will be the solution? Hmmm.
Re: minimize+Restore Loses all my gadgets
Posted: Wed Oct 29, 2025 10:03 pm
by BarryG
It's definitely some kind of event with redraw issue. You need to reproduce it with a small standalone version to find out. What does your main event loop look like? Can you show us? Make sure it doesn't have any unnecessary delays.