Page 1 of 1

Disable changing of the window size?

Posted: 10 Oct 2016 07:49
by (_osd_)
Hello,
how can one disable the changing of the cmd-window? So that you can't pull it with your mouse to make
it bigger/smaller than the mode command made it.

Re: Disable changing of the window size?

Posted: 10 Oct 2016 11:05
by aGerman
As far as I know you can't.

Steffen

Re: Disable changing of the window size?

Posted: 10 Oct 2016 14:04
by misol101
This works for me (Win7), no idea if it's the same for all Windows versions. Try it if you don't mind using an external program.

Code: Select all

#define _WIN32_WINNT 0x0501

#include <windows.h>
#include <stdio.h>

int main(void)
{
   long oldValue;
   HWND hConsoleWnd = GetConsoleWindow();

   if (hConsoleWnd) {
      
      oldValue = GetWindowLongPtr(hConsoleWnd, GWL_STYLE);

      if (oldValue & WS_THICKFRAME)
         oldValue &= ~(WS_THICKFRAME);
      else
         oldValue |= WS_THICKFRAME;

      SetWindowLongPtr(hConsoleWnd, GWL_STYLE, oldValue);
   } else {
      printf("Unable to get console window\n");
      return 1;
   }
   return 0;
}

Re: Disable changing of the window size?

Posted: 10 Oct 2016 14:24
by aGerman
Yes using a 3rd party like that you can toggle the ability to resize the window. It doesn't protect you from removing the programm call from the script though :wink:

Steffen