Thread: Maximize

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Question Maximize

    I want to make a window that contains only a minimize button, not a maximize button. And that works fine.
    However, the system menu still contains the option "maximize", which is not good. I don't want to remove the system menu completely, only the maximize-item.
    How?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Cant get rid of the box without removing sysmenu, but you can remove the WS_MAXIMIZEBOX style so the maximise option is greyed out. Is this what you want?

    Code:
    #include <windows.h>
    #include <tchar.h>
    
    LRESULT CALLBACK WndProc(HWND hWnd,UINT msg, WPARAM wParam, LPARAM lParam){
    
    	switch(msg){
    	case WM_CLOSE:
    		PostQuitMessage(0);
    		break;
    	default:
    		return DefWindowProc(hWnd, msg, wParam, lParam);
    	}
    
    	return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int nShow){
    
    	TCHAR szWindowName[]= _T("Magos");
    	WNDCLASSEX wc= {0};
    	HWND hWnd;
    	MSG msg;
    	DWORD dwStyle;
    
    	wc.cbSize= sizeof(WNDCLASSEX);
    	wc.style= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
    	wc.lpfnWndProc= WndProc;
    	wc.hInstance= hInst;
    	wc.hIcon= LoadIcon(NULL, IDI_WINLOGO);
    	wc.hCursor= LoadCursor(NULL,IDC_ARROW);
    	wc.lpszClassName= szWindowName;
    	wc.hbrBackground= CreateSolidBrush(RGB(255, 255, 255));
    	wc.hIconSm= LoadIcon(NULL, IDI_WINLOGO);
    
    	if(!RegisterClassEx(&wc))return EXIT_FAILURE;
    
    	dwStyle = WS_OVERLAPPEDWINDOW &  ~WS_MAXIMIZEBOX;
    
    	hWnd= CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES,szWindowName,
    		szWindowName,dwStyle,CW_USEDEFAULT,CW_USEDEFAULT,
    		400,400,HWND_DESKTOP,NULL,hInst,NULL);
    	
    	if(!hWnd) return EXIT_FAILURE;
    	
    
    	ShowWindow(hWnd, nShow);
    	UpdateWindow(hWnd);
    
    	while(GetMessage(&msg, NULL, 0, 0) > 0){
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    
    	return msg.wParam;
    
    
    }

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Yes, I know how to disable the actual buttons.
    But the option to maximize the window is still available in the system menu, as you can see in the picture:
    (The language is in Swedish, but the Maximize item is the selected one)

    http://war3pub.net/upload/files/maxwindow.jpg
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    Unregged
    Guest
    Magos,

    I never tried it but what about following:

    Get the handle of the System menu by calling GetSystemMenu,hWnd, FALSE and modify it by counting up all the Items, scanning thru them for the Maximize one and remove it using RemoveMenu and it's ID ?

    Happy Coding.
    Jim

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Weird....My XP-Box disables the Maximise in the sysmenu if I do what I discribed above....but on yours it doesnt seem to so????

    You can do what Jim discribed above. Also..If it helps..Add the following handler;
    Code:
    case WM_SYSCOMMAND:
    	if(wParam == SC_MAXIMIZE) return 0;
    	else DefWindowProc(hWnd, msg, wParam, lParam);
    	break;
    And the window wont maximise at all....buttons or no buttons

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Maximize button notification
    By mrafcho001 in forum Windows Programming
    Replies: 2
    Last Post: 12-26-2005, 10:31 PM
  2. Maximize All...
    By Geolingo in forum Tech Board
    Replies: 2
    Last Post: 09-01-2003, 07:05 PM
  3. minimize and maximize
    By Wick in forum Windows Programming
    Replies: 2
    Last Post: 08-20-2003, 10:37 PM
  4. Stop window from being able to maximize
    By pinkcheese in forum Windows Programming
    Replies: 9
    Last Post: 07-12-2002, 03:09 PM
  5. Disabling maximize button and movable border
    By Garfield in forum Windows Programming
    Replies: 6
    Last Post: 01-26-2002, 02:21 PM