Code: Select all
sm.SMALL_RECT
cinfo.CONSOLE_SCREEN_BUFFER_INFO
newX = 40
newY = 25
co = (newY * 65536) + (newX)
OpenConsole()
handle=GetStdHandle_(#STD_OUTPUT_HANDLE)
If handle
GetConsoleScreenBufferInfo_(handle,cinfo)
oldY = cinfo\dwSize / 65536
oldX = cinfo\dwSize & $FFFF
If(oldX * oldY) > (newX * newY)
sm\left = 0
sm\top = 0
sm\right = newX-1
sm\bottom = newY-1
SetConsoleWindowInfo_(handle,1,sm)
SetConsoleScreenBufferSize_(handle,co)
Else
SetConsoleScreenBufferSize_(handle,co)
sm\left = 0
sm\top = 0
sm\right = newX-1
sm\bottom = newY-1
SetConsoleWindowInfo_(handle,1,sm)
EndIf
EndIf
PrintN("New console size: "+Str(newX)+"x"+Str(newY))
PrintN("Press any key to close")
Input()
CloseConsole()
End