Disable changing of the window size?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
(_osd_)
Posts: 25
Joined: 01 Mar 2015 07:41

Disable changing of the window size?

#1 Post by (_osd_) » 10 Oct 2016 07:49

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.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Disable changing of the window size?

#2 Post by aGerman » 10 Oct 2016 11:05

As far as I know you can't.

Steffen

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Disable changing of the window size?

#3 Post by misol101 » 10 Oct 2016 14:04

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;
}

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Disable changing of the window size?

#4 Post by aGerman » 10 Oct 2016 14:24

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

Post Reply