I’ve got a Delphi app that is running in an environment where it gets minimized by another aggressive app that is trying to seize the screen entirely (it’s POS stuff). When a second application is started it get hunts down the windows and minimizes them, probably by enumerating the windows and hitting them with a ‘ShowWindow(handle,SW_MINIMIZE)’.
It seems to me that the thing to do is to pick up these commands and block resize/minimize messages to the window. I’ve tried hacking around a few handlers to try and capture this behaviour, but still the SW_MINIMIZE will hide it. And Winsight is not showing me much other than the notification messages that something is resizing etc. I’ve put in a message handler for WMSysCommand messages, but that only seems to stop actions like the minimize button being clicked. And I’ve tried overriding the WndProc function to filter messages but that doesn’t cut it either.
If anyone could shed some light on what happens when the ShowWindow(handle,SW_MINIMIZE) call is inflicted on an application I’d be very grateful!
Thanks
Terry
What happens when
ShowWindowis called withSW_MINIMIZEas ‘nCmdShow’ is that the window manager minimizes the window.The system will send various notification messages, some more important to be able to carry out the minimization and the application can act upon, like
WM_WINDOWPOSCHANGING,WM_GETMINMAXINFO,WM_NCCALCSIZE, or some just to notify, likeWM_WINDOWPOSCHANGED,WM_MOVE,WM_SIZE, but normally, none of these is for blocking the operation.The cleanest way, I think, if you can decide that the minimization is unexpected, is to respond to a
WM_SIZEmessage when ‘wParam’ isSIZE_MINIMIZED, and restore your window accordingly. Then your form will bounce back from the taskbar:I don’t have any clear idea about how you might decide either a minimization is unexpected or not but it would seem you do. User initiated actions would cause a
WM_SYSCOMMANDto be send, but I don’t know if some of the OS features also do that and you’ll be able to differentiate if the OS minimizes the window or the aggressive application.