CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2009
    Posts
    9

    How to create a Window and disable maximize/resize?

    I am using the CreateWindowEx to create my main program window, however every buttons on the caption and resizing is on. I wish to disable the maximize button and disable resizing but couldn't find anything online.
    How can I do that?

  2. #2
    Join Date
    Nov 2007
    Posts
    613

    Re: How to create a Window and disable maximize/resize?

    To remove completely the buttons you should remove the WS_MINIMIZEBOX and WS_MAXIMIZEBOX styles. Use the GetWindowLong and SetWindowLong functions.

  3. #3
    Join Date
    Sep 2009
    Posts
    9

    Re: How to create a Window and disable maximize/resize?

    Ah I got it. I was using WS_OVERLAPPEDWINDOW instead of WS_OVERLAPPED so the buttons where all included by default. Thanks!

    so is WS_POPUP the only way to remove the window border?

  4. #4
    Join Date
    Apr 2009
    Posts
    598

    Re: How to create a Window and disable maximize/resize?

    I use CreateWindowEx(WS_EX_TOOLWINDOW, ...), for the creation of a window with just a thin title bar, good enough to move the window and slim enough to be pretty.

  5. #5
    Join Date
    Sep 2009
    Posts
    9

    Re: How to create a Window and disable maximize/resize?

    I try to use:
    SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU);
    and doesn't seem to work, maybe I am doing something wrong?

  6. #6
    Join Date
    Jul 2009
    Location
    Genova - Italy
    Posts
    38

    Re: How to create a Window and disable maximize/resize?

    Hello!

    You can operate by 2 ways:

    1. Disable voices in sysmenu:
    Code:
    // get the styles and properties of your window
    DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE); 
    dwStyle &= ~(WS_MAXIMIZE|WS_SIZEBOX );
    // set the window with style without titlebar and sizebox
    SetWindowLong(hWnd, GWL_STYLE, dwStyle);
    2. Delete those voices from your sysmenu
    Code:
    // hWnd is the handle of your main window
    HMENU hMenu = GetSystemMenu(hWnd, FALSE);
    DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND) ;
    DeleteMenu(hMenu, SC_SIZE, MF_BYCOMMAND) ;
    About displaying window without any border, I use following function:
    Code:
    CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST,szWindowClass, szTitle, WS_THICKFRAME|WS_POPUP,.......);
    tell me if its works!

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