Windows API returning zero

Windows specific questions.
Post Reply
deltarho[1859]
Posts: 4675
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Windows API returning zero

Post by deltarho[1859] »

#include once "windows.bi"

Dim As Handle hOut = GetStdHandle( STD_OUTPUT_HANDLE )
Print SetConsoleScreenBufferSize(hOut, Type <COORD>(40, 60))
Print "FreeBASIC"
Sleep
Why is the API returning zero?
deltarho[1859]
Posts: 4675
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Windows API returning zero

Post by deltarho[1859] »

<COORD>(100, 40)

That returned 1

I need to read dwSize [in] in Parameters.a few times. It looks it was written on a Friday afternoon after a long liquid lunch.
adeyblue
Posts: 350
Joined: Nov 07, 2019 20:08

Re: Windows API returning zero

Post by adeyblue »

dwSize
A COORD structure that specifies the new size of the console screen buffer, in character rows and columns. The specified width and height cannot be less than the width and height of the console screen buffer's window. The specified dimensions also cannot be less than the minimum size allowed by the system.
If you're making the window smaller, you have to resize the window then optionally the buffer.
If you're making the window bigger, you have to resize the buffer first then the window.

SetConsoleScreenBufferInfoEx will let you resize them both at the same time. You'll need to use GetConsoleScreenBufferInfoEx first to populate all the things you don't want to change like the colours or the cursor position.

The console buffer is what the console window shows. It doesn't make sense for it to be smaller than the window, so they don't let you do it.
deltarho[1859]
Posts: 4675
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Windows API returning zero

Post by deltarho[1859] »

Thanks adeyblue.

It looks like my opening post fell foul of your 'bold' sentence above.

<COORD>(100, 40) exceeded the window, so was OK.
Post Reply