Preventing a window from becoming maximized
-
1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled. 2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window. Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".
-
1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled. 2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window. Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".
-
Catch the WM_SIZE: OnSize( UINT nType, int cx, int cy ); if nType==SIZE_MAXIMIZED don't let the message go further. Mickey :)
Thanks; however this does not help. The OnSize description states: The framework calls this member function AFTER the window's size has changed. I fact, this filtering in OnSize does not change the result. A call of CDialog::OnSize will be generated by the wizzard in OnSize. I admit that I don't know, what CDialog::OnSize does (this will be generated by the wizzard in OnSize), but no matter if I call it or not, the result is the same. In the meantime I tested my own suggestion, posting a WM_SIZE message with SIZE_RESTORED. This does not work either; I'd like to know, why. The message goes through properly, it appears in OnSize as well, with the identical parameters, as a RESTORE from the minimized state generates - but restoring does not happen. SetWindowPlacement works, but that needs more preparation: not only the size, but the position of the last non-maximized window too has to be recorded. Not a big deal, but all this is nonsense.
-
Thanks; however this does not help. The OnSize description states: The framework calls this member function AFTER the window's size has changed. I fact, this filtering in OnSize does not change the result. A call of CDialog::OnSize will be generated by the wizzard in OnSize. I admit that I don't know, what CDialog::OnSize does (this will be generated by the wizzard in OnSize), but no matter if I call it or not, the result is the same. In the meantime I tested my own suggestion, posting a WM_SIZE message with SIZE_RESTORED. This does not work either; I'd like to know, why. The message goes through properly, it appears in OnSize as well, with the identical parameters, as a RESTORE from the minimized state generates - but restoring does not happen. SetWindowPlacement works, but that needs more preparation: not only the size, but the position of the last non-maximized window too has to be recorded. Not a big deal, but all this is nonsense.
-
1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled. 2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window. Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".
You must also process the CWnd::OnGetMinMaxInfo or handle WM_GETMINMAXINFO. If that does not work, override CWnd::PreTranslateMessage and trap the sizing calls. The memories of a man in his old age are the deeds of a man in his prime.
-
1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled. 2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window. Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".
Thanks for the suggestions. WM_WINDOWPOSCHANGING appears a good solution, but it does not say, when the window will be maximized, i.e. it would need a "calibration" to get the actual maximum size. In the meantime I solved the problem already, with a combination of OnSize and OnMove plus SetWindowPlacement as correction of MAXIMIZE. However it is not a nice solution. Sometimes OnSize, sometimes OnMove is the first, when both will be called. Lots of work-around only to prevent the system from doing something, what it should not do per definition. Anyway, now it's working, but I'm now trying Blake's suggestion, GetMinMaxInfo. This function gets called before each MAXIMIZE (I have expected a call at MINIMIZE at well, even though it does not matter in my case). Simply to prevent MAXIMIZE to a large size is very simple this way. However, there is still a small problem: it positions the window to the upper left corner; one has to work around it. Once more, thanx for the help.