I am trying to incorporate functionality into an application so that the user can hit the Minimize button on a window and the window will minimize to a particular size. I am trying to do this with the Minimize, Maximize, and Close buttons on the top right of the window (standard window functions). My problem is I am not sure how to do it. If the user resizes the window, I am preventing the window from going below a specific size. But is there any way to do the same thing when the minimize button is hit or I am forced to allow the window to be fully minimized? This is not C++ or MFC, I am having to do this in an application that is written in C. Any suggestions?
January 6th, 2004, 05:57 PM
Wow I didn't know you could make an application with minimize, maximize and close buttons using C only. Make it easy on yourself use MFC.......Unless of course you are referring to the buttons on the DOS console window.
January 6th, 2004, 06:44 PM
This is non standard window's behaviour.
Don't do it.
Errr, did I say :
DON'T DO IT !
Your users will chase you out of town and string you up from the nearest tree for changing standard windows behaviour.
Find another way of doing it : I've always found an item on the file menu (with associated shortcut key) works really well.
I've written a couple of apps which minimise themselves to the system tray (bottom right icons) so as not to block up the application bar at the bottom of windows.
And I always did it this way.
January 6th, 2004, 06:46 PM
And again before I'm flamed it should be on the 'View' menu, but I've always considered this menu to be to do with views in the app, not about the app.
Ho hum, I suppose someones going to go broadsides with me now (like in Pirates of the Carribean).
Guns ready !
January 6th, 2004, 10:10 PM
I do realize this is not the normal behavior for windows and I agree I shouldn't be doing this. The problem is that those who are in charge think we should be doing it and I have been labored with the task of trying to figure out how. I cannot use MFC or C++, the application is written entirely in C and the file that I am modifying is written in C. So I am left with no choice but to use C. Also, I cannot use a menu, it was explicitly asked that it be when they hit the Minimize button. If all else fails, I will just let windows do what it is currently doing.
January 6th, 2004, 10:52 PM
if u r doing windows programming than it is easy. i cant say anything if it is related to DOS. hey for windows all u have to do is to override the window minimize message. and in that set the size of window using SetWindowPos() API.
nd for handling the minimize operation u have to override WM_PAINT.
hdc = BeginPaint(hwnd, &ps);
// Determine whether the window is minimized.
SetWindowPos(/*Here specify the size of the window and other parameters*/);
Maybe this works.
January 7th, 2004, 03:13 AM
You can handle WM_SYSCOMMAND. When you minimize, maximize, restore a window it will be send with parameter SC_MINIMIZE, SC_MAXIMIZE, SC_RESTORE.
January 7th, 2004, 08:52 AM
Look at WM_GETMINMAXINFO. It may give you what you need.
January 13th, 2004, 02:52 PM
Look for WM_SYSCOMMAND and handle the SC_MINIMIZE
yourself. In your case, you resize the window.
Don't call DefWindowProc( ) when you get the SC_MINIMIZE.
LRESULT WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
// the big switch
// your stuff
if ((wParam&0xFFF0) == SC_MINIMIZE)
// calculate X, Y, CX and CY for the size of the window
// when the user clicks Minimize, you resize instead
X = ??
Y = ??
CX = ??
CY = ??
Flags = ??
SetWindowPos(hWnd, HWND_TOP, X, Y, CX, CY, Flags);
// don't use DefWindowProc - we've handled the msg
// the rest of your stuff
return DefWindowProc(hWnd, Msg, wParam, lParam);
This is not a good idea. As Darwen said, you are no longer
complying with the standard Windows behavior.
People won't expect your window to act like this.