adjust width on c++ program
How can i adjust width on the window of a c++ program so when开发者_C百科 the user runs the program,it will automatically be at the desirable width.
Thanks
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);
}
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
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:
- What windowing system are you using? In conjunction with which C++ compiler?
- 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.
精彩评论