Page 1 of 2
Console resize
Posted: Tue Jul 29, 2008 8:25 pm
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

Posted: Tue Jul 29, 2008 8:33 pm
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.
Posted: Tue Jul 29, 2008 9:03 pm
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...
Posted: Sun Aug 03, 2008 4:23 pm
by xSoNiCaSx
Still no answer...
Can anybody help?
Posted: Sun Aug 03, 2008 4:38 pm
by SFSxOI
Posted: Mon Aug 04, 2008 2:10 am
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)
Posted: Mon Aug 04, 2008 2:50 am
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()
Posted: Mon Aug 04, 2008 3:27 am
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
Posted: Mon Aug 04, 2008 3:28 am
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.
Posted: Mon Aug 04, 2008 4:11 am
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:
Posted: Mon Aug 04, 2008 12:47 pm
by Sparkie
You are correct netmaestro. I'll dig a little deeper and see what I can find.
Posted: Mon Aug 04, 2008 5:36 pm
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()
Posted: Mon Aug 04, 2008 5:43 pm
by netmaestro
Looks very good here!

Posted: Mon Aug 04, 2008 8:01 pm
by xSoNiCaSx
Yep, I wanted that the console could not be resized at all.
Big thanks, Sparkie.

Thank you all, guys! :roll:

Re:
Posted: Tue Nov 05, 2024 4:10 pm
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?