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?
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.
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.
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 !
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.
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.
You can handle WM_SYSCOMMAND. When you minimize, maximize, restore a window it will be send with parameter SC_MINIMIZE, SC_MAXIMIZE, SC_RESTORE.
Look at WM_GETMINMAXINFO. It may give you what you need.
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.
This is not a good idea. As Darwen said, you are no longer
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);
complying with the standard Windows behavior.
People won't expect your window to act like this.