Thread: How can I avoid a window from being resized?

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    35

    How can I avoid a window from being resized?

    I don't want that the user can change the size of the main window of the application.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Create the window without the WS_THICKFRAME style.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    35
    I create the main Window using:

    Code:
    hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Windows App",       /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               CW_USEDEFAULT,       /* Windows decides the position */
               CW_USEDEFAULT,       /* where the window ends up on the screen */
               CW_USEDEFAULT,       /* The programs width */
               CW_USEDEFAULT,       /* and height in pixels */
               HWND_DESKTOP,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               hThisInstance,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
               );
    If I process the WM_GETMINMAXINFO, what do I have to do so that the window can't be resized by the user?

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    26
    You used WS_OVERLAPPEDWINDOW, that is the problem.
    This is what it does

    WS_OVERLAPPEDWINDOW: Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style.

  6. #6
    Registered User
    Join Date
    Jul 2004
    Posts
    35
    I want a normal window except for the fact that the user can't resize it. What WS_ .. do I have to use instead of WS_OVERLAPPEDWINDOW?

  7. #7
    Registered User
    Join Date
    Nov 2001
    Posts
    38
    //constrains window size to 640x480

    case WM_GETMINMAXINFO:
    {
    LPPOINT lppt;

    lppt = (LPPOINT)lParam; // lParam points to array of POINTS

    lppt[3].x = 640;
    lppt[4].x = 640;
    lppt[3].y = 480;
    lppt[4].y = 480;

    return DefWindowProc(hwnd, msg, wParam, lParam);
    }

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Quote Originally Posted by dit6a9
    I want a normal window except for the fact that the user can't resize it. What WS_ .. do I have to use instead of WS_OVERLAPPEDWINDOW?
    WS_OVERLAPPEDWINDOW&~WS_THICKFRAME to create a window with a non-sizing border while retaining the other styles included with WS_OVERLAPPED. WM_GETMINMAXINFO is used to limit the dimensions of a window that can be resized by the user which is what I originally thought you were after.
    Last edited by Ken Fitlike; 08-02-2004 at 10:08 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    Registered User
    Join Date
    Jul 2004
    Posts
    35
    Many thanks for your answers. I have used
    Code:
    WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
    (leaving out WS_THICKFRAME) and it works fine.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  4. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM