Console resize

Just starting out? Need help? Post your questions and find answers here.
xSoNiCaSx
User
User
Posts: 15
Joined: Mon Dec 17, 2007 5:07 pm

Console resize

Post by xSoNiCaSx »

Hi all.

I have this little problem. I set my console's screen buffers size to 80x25, and I want it to stay that way. When resizing console's window it can be shrunk down (with scrollbars on the left, and the bottom).
I want to have the console unresizable. Is there any way to do this? I suppose it should be some kind of a code in the loop, or something.

Please help :oops:
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

there should be a window-massage via API that sets the console-window to unresizable.
(if you are not working on windows, please tell.)

but please wait for other answers, I don't know the appropriate API,
I just know it should be avaliable.
oh... and have a nice day.
xSoNiCaSx
User
User
Posts: 15
Joined: Mon Dec 17, 2007 5:07 pm

Post by xSoNiCaSx »

Yeah, I'm on windows.

Thanks.

Window-Message you say?... Well... I think I saw that thing somewhere... If the console window behaves like a simple window, it should be possible...
I'll search MSDN for it.
Although I don't think I will find the answer...
xSoNiCaSx
User
User
Posts: 15
Joined: Mon Dec 17, 2007 5:07 pm

Post by xSoNiCaSx »

Still no answer...

Can anybody help?
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

maybe this might be what you need?: http://msdn.microsoft.com/en-us/library/ms682087.aspx
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

These look interesting, I wonder how you can get the console handle of a PB console, Can we use the return value from OpenConsole() ? (I can't test as I'm at work at the moment)
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Based on http://www.purebasic.fr/english/viewtop ... 320#124320

Code: Select all

OpenConsole()
stdout = GetStdHandle_(#STD_OUTPUT_HANDLE)
With cCoord.COORD
  \x = 80
  \y = 25
EndWith
SetConsoleScreenBufferSize_(stdout, PeekL(cCoord))
Input()
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

nice you know and use this (besides it's on-the-fly declaring),
but for better understanding for beginners,
I would replace this:

Code: Select all

With cCoord.COORD
  \x = 80
  \y = 25
EndWith 
with that:

Code: Select all

Define cCoord.COORD
  cCoord\x = 80
  cCoord\y = 25
oh... and have a nice day.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

xSoNiCaSx wrote:When resizing console's window it can be shrunk down (with scrollbars on the left, and the bottom).
I want to have the console unresizable. Is there any way to do this?
@Sparkie: Here your code is successfully preventing the console window from being resized larger, but is allowing it to be resized smaller and adding scrollbars. I don't believe he wants this.
BERESHEIT
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Kaeru Gaman wrote:nice you know and use this (besides it's on-the-fly declaring),
but for better understanding for beginners,
I would replace this:

Code: Select all

With cCoord.COORD
  \x = 80
  \y = 25
EndWith 
with that:

Code: Select all

Define cCoord.COORD
  cCoord\x = 80
  cCoord\y = 25
It's the same thing. And it's not that better for beginnners. Everybody knows what a With : EndWith section is :roll:
Proud registered Purebasic user.
Because programming should be fun.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

You are correct netmaestro. I'll dig a little deeper and see what I can find.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

How about this one?

Code: Select all

OpenConsole() 
ConsoleTitle("Console fixed size")

stdout = GetStdHandle_(#STD_OUTPUT_HANDLE) 

OpenLibrary(0, "kernel32.dll")
hWin = CallFunction(0, "GetConsoleWindow")
CloseLibrary(0)
;...Remove the Size option from the menu
system_menu = GetSystemMenu_(hWin, #False) 
DeleteMenu_(system_menu, 2, #MF_BYPOSITION) 
DrawMenuBar_(hWin) 

With windowSize.SMALL_RECT
  \left = 0
  \top = 0
  \right = 79
  \bottom = 24
EndWith
setConsoleWindowInfo_(stdout, #True, @windowSize)

With bufferSize.COORD
  \x = 80 
  \y = 25 
EndWith 
SetConsoleScreenBufferSize_(stdout, PeekL(bufferSize))

Input()
CloseConsole()
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Looks very good here! 8)
BERESHEIT
xSoNiCaSx
User
User
Posts: 15
Joined: Mon Dec 17, 2007 5:07 pm

Post by xSoNiCaSx »

Yep, I wanted that the console could not be resized at all.

Big thanks, Sparkie. :wink:
Thank you all, guys! :roll: :wink:
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Re:

Post by Armoured »

Sparkie wrote: Mon Aug 04, 2008 5:36 pm How about this one?

Code: Select all

OpenConsole() 
ConsoleTitle("Console fixed size")

stdout = GetStdHandle_(#STD_OUTPUT_HANDLE) 

OpenLibrary(0, "kernel32.dll")
hWin = CallFunction(0, "GetConsoleWindow")
CloseLibrary(0)
;...Remove the Size option from the menu
system_menu = GetSystemMenu_(hWin, #False) 
DeleteMenu_(system_menu, 2, #MF_BYPOSITION) 
DrawMenuBar_(hWin) 

With windowSize.SMALL_RECT
  \left = 0
  \top = 0
  \right = 79
  \bottom = 24
EndWith
setConsoleWindowInfo_(stdout, #True, @windowSize)

With bufferSize.COORD
  \x = 80 
  \y = 25 
EndWith 
SetConsoleScreenBufferSize_(stdout, PeekL(bufferSize))

Input()
CloseConsole()
Hi
Is it possible to do the opposite, making the same window resizable again?
Post Reply