Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

LiTWoL

resize Console Window in c++

This topic is 5229 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am working on a small game for some time now and i''m ready to put a demo online but i have small problem. every time i run the game console window size is set to detaults ( 80 x24 i think) but i need the size of buffer and window size to 100x40. someone please give me code example how to resize console window. please note i did find few links but they use handles to do the sizing but i have no clue about handles yet. so please instead of redirecting me to someplace that explains how to resize by using handles post an explanation of what i need to do step by step. thank you in advance this will help me alot. Email: d_3_lvl_0_n_s_oleg@hotbox.ru AIM: LiTWoL contact me if you have any comments or suggestions.

Share this post


Link to post
Share on other sites
Advertisement

bool SetConsoleSize(const COORD size) {
if (!SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), size))
return false;

CONSOLE_SCREEN_BUFFER_INFO csbi;

if (!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
return false;

SMALL_RECT sr;

sr.Left = 0;
sr.Top = 0;
sr.Right = size.X - 1;
sr.Bottom = size.Y - 1;

if (!SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &sr))
return false;

return true;
}


Remember to #include windows.h


Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

Share this post


Link to post
Share on other sites
thank you very much! this worked perfectly.

Email: d_3_lvl_0_n_s_oleg@hotbox.ru
AIM: LiTWoL
contact me if you have any comments or suggestions.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!