Page 1 of 1
Resize Console Buffer
Posted: Sat Apr 02, 2011 1:41 am
by armixeight
I have a program that runs with the OpenConsole() command and i would like to get rid of the scroll bar on the side.
I have read around for awhile about how to remove the scroll bar and has been the result of resizing the buffer to 80x24.
The problem is i can't seem to implement the resize in purebasic. It can be done in C++ and languages like that because of code I found on the Microsoft MSDN's example areas.
Basically it needs to look something like the Dwarf Fortress and Rogue games, where there is no scroll bar.
Thank you to how ever helps, because you will know that you saved someone hours of console scripting.
Please somebody help.

Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 1:52 am
by TomS
If it's on MSDN it can probably done with PB.
How about a link?
Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 2:17 am
by armixeight
http://msdn.microsoft.com/en-us/library ... S.85).aspx
And here is some code that I tried to make: (no luck though ...
Code: Select all
OpenConsole()
stdout.l=GetStdHandle_(#STD_OUTPUT_HANDLE)
NewSize.COORD
NewSize\X=80
NewSize\Y=23
SetConsoleScreenBufferSize_(stdout, @NewSize)
Input()
Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 3:15 am
by TomS
I found this
http://purearea.net/pb/CodeArchiv/Input ... onsole.pbi
and in it there was a procedure to set the buffer size.
Code: Select all
Procedure ConsoleBufferSize(handle.i, characterWidth.i, characterHeight.i)
Protected consoleInfo.CONSOLE_SCREEN_BUFFER_INFO
Protected rect.SMALL_RECT
GetConsoleScreenBufferInfo_(handle, @consoleInfo)
If characterWidth < consoleInfo\dwSize\x Or characterHeight < consoleInfo\dwSize\y
If characterWidth < 13 ;Smaller thant 13 seems not possible
rect\right = 13 - 1
characterWidth = 13
ElseIf characterWidth < consoleInfo\dwSize\x
rect\right = characterWidth - 1
Else
rect\right = consoleInfo\dwSize\x - 1
EndIf
If characterHeight <= 0
rect\bottom = 1 - 1
characterHeight = 1
ElseIf characterHeight < consoleInfo\dwSize\y
rect\bottom = characterHeight - 1
Else
rect\bottom = consoleInfo\dwSize\y - 1
EndIf
SetConsoleWindowInfo_(handle, 1, @rect)
EndIf
SetConsoleScreenBufferSize_(handle, characterWidth + (65536 * characterHeight))
EndProcedure
OpenConsole()
ConsoleBufferSize(GetStdHandle_(#STD_OUTPUT_HANDLE), 79, 30)
Input()
Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 3:28 am
by Demivec
@armixeight: a note regarding the parameters for the function SetConsoleScreenBufferSize_(). It takes a COORD structure, not a pointer to a COORD structure.
Like this:
Code: Select all
SetConsoleScreenBufferSize_(stdout, newSize\y << 16 + newSize\x)
Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 10:24 am
by eesau
Dwarf Fortress' window isn't a console, it's rendered graphics. That's what I suggest you do as well, as working with a console only is very limited.
Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 11:44 am
by armixeight
TomS:
Thank you so very much, that is exactly what I needed. Thank you!
Demivec:
I would also like to thank you for helping me understand I bit more about COORD structures and how to implement them.
And finally essau:
You said "Dwarf Fortress' window isn't a console, it's rendered graphics. That's what I suggest you do as well".
How would you accomplish this Rendered Graphics alternative. I really would like to learn about this. Thanks.
Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 12:25 pm
by TomS
Demivec wrote:...SetConsoleScreenBufferSize_() [...] takes a COORD structure, not a pointer to a COORD structure
Figured that one, too. But didn't work either
Seems like the SetConsoleWindowInfo() with a matching RECT is mandatory.
Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 2:36 pm
by Demivec
TomS wrote:Demivec wrote:...SetConsoleScreenBufferSize_() [...] takes a COORD structure, not a pointer to a COORD structure
Figured that one, too. But didn't work either
Seems like the SetConsoleWindowInfo() with a matching RECT is mandatory.
@TomS: It had foiled my first attempts also.
For the sake of completeness, here's the original example with the needed change extracted from the helpful code in the CodeArchive:
Code: Select all
OpenConsole()
stdout=GetStdHandle_(#STD_OUTPUT_HANDLE)
newSize.COORD
newSize\x=80
newSize\y=23
rect.SMALL_RECT
rect\right = newSize\x - 1
rect\bottom = newSize\y - 1
SetConsoleWindowInfo_(stdout, 1, @rect)
SetConsoleScreenBufferSize_(stdout, newSize\x + newSize\y << 16)
Re: Resize Console Buffer
Posted: Sat Apr 02, 2011 4:33 pm
by Zach
From what I can tell it's an ASCII art game, at least according to its Features page..
Extended ASCII character set rendered in 16 colors (including black) as well as 8 background colors (including black).
How that ultimately gets to the screen I don't know.. So maybe that's what he was saying.. Anyhow you'd probably want to look at something like Graphical Console mode, but that is restricted to Windows only, so cross-platform would not work if that were one of your goals.