CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2002
    Location
    Nebraska
    Posts
    25

    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

  2. #2
    Join Date
    Jan 2004
    Location
    Earth
    Posts
    567
    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

  3. #3
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940
    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.

  4. #4
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940
    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.

  5. #5
    Join Date
    May 2002
    Location
    Nebraska
    Posts
    25
    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

  6. #6
    Join Date
    Jan 2004
    Location
    Altos
    Posts
    168
    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"

  7. #7
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150
    You can handle WM_SYSCOMMAND. When you minimize, maximize, restore a window it will be send with parameter SC_MINIMIZE, SC_MAXIMIZE, SC_RESTORE.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635
    Look at WM_GETMINMAXINFO. It may give you what you need.

  9. #9
    Join Date
    Aug 2001
    Location
    Texas
    Posts
    645
    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
  •  





Click Here to Expand Forum to Full Width

Featured