-
January 6th, 2004, 06:15 PM
#1
Minimize question????
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?
"Have you ever danced with the devil in the pale moonlight" - Jack Nicholson as Joker, Batman
-
January 6th, 2004, 06:57 PM
#2
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.
TDM
-
January 6th, 2004, 07:44 PM
#3
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.
Darwen.
-
January 6th, 2004, 07:46 PM
#4
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 !
Darwen.
-
January 6th, 2004, 11:10 PM
#5
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.
"Have you ever danced with the devil in the pale moonlight" - Jack Nicholson as Joker, Batman
-
January 6th, 2004, 11:52 PM
#6
Hi man,
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.
For eg
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
// Determine whether the window is minimized.
if (IsIconic(hwnd))
{
SetWindowPos(/*Here specify the size of the window and other parameters*/);
}
Maybe this works.
Regards Bandit
"I came"
"I saw"
"I conquered"
-
January 7th, 2004, 04:13 AM
#7
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, 09:52 AM
#8
Look at WM_GETMINMAXINFO. It may give you what you need.
-
January 13th, 2004, 03:52 PM
#9
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.
Code:
LRESULT WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
// the big switch
switch(Msg)
{
// your stuff
case WM_SYSCOMMAND:
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
return 0;
}
break;
// 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.
Last edited by cvogt61457; January 20th, 2004 at 03:18 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|