Kevin Dong
Kevin Dong

Reputation: 5369

No winapi function for setting the size console window?

I can change the size of console window like this:

mode con cols=64 lines=32

Though there are many api functions for console subsystem, I could not find any function for setting the size of console window.

Is it able to set the size of console window without calling

system ("mode con cols=64 lines=32");

Thanks.

Upvotes: 0

Views: 1401

Answers (1)

Ken White
Ken White

Reputation: 125757

Use SetConsoleWindowInfo

BOOL WINAPI SetConsoleWindowInfo(
  _In_  HANDLE hConsoleOutput,
  _In_  BOOL bAbsolute,
  _In_  const SMALL_RECT *lpConsoleWindow
);

hConsoleOutput is a screen buffer handle returned by CreateConsoleScreenBuffer.

Upvotes: 2

Related Questions