akageek
akageek

Reputation: 87

adjust width on c++ program

How can i adjust width on the window of a c++ program so when the user runs the program,it will automatically be at the desirable width.

Thanks

Upvotes: 1

Views: 331

Answers (3)

Erik
Erik

Reputation: 91300

This adjusts the console on windows.

COORD s = { 120, 2000 };
SMALL_RECT sr = { 0, 0, 119, 49 };
CONSOLE_SCREEN_BUFFER_INFO sbi = { 0 };
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &sbi);
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), s);
if ( (sbi.srWindow.Right - sbi.srWindow.Left) != (sr.Right - sr.Left) ) {
    SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &sr);
}

Upvotes: 3

Component 10
Component 10

Reputation: 10497

Your question raises more questions, but if you can answer the following, you may be a few steps nearer to getting where you want to be:

  1. What windowing system are you using? In conjunction with which C++ compiler?
  2. What do you define as 'desireable width?' Desireable for whom?

Now, with you answers to these questions, you should be able to search the web and come up with reference material and examples inside of about 10 minutes. Then try plugging into your design the answer from question two.

When you've done all this and it still doesn't work, come back here with more details and some real code.

Upvotes: 0

Jim Blackler
Jim Blackler

Reputation: 23169

If your application is for the Win32 platform and uses a call to CreateWindow, this can be adjusted by modifying the sixth parameter http://msdn.microsoft.com/en-us/library/ms632679(v=vs.85).aspx

Upvotes: 0

Related Questions