EDN Admin
Well-known member
Okay, here is the problem Ive had; there was no "simple" answer for "maximizing" the c++ console window. Every article or response Ive read either refers to c# or, even worse, to a function requiring upper level knowledge of manipulating the Console window.
For all others who have run into this problem, if you are running XP or Vista, you can use exactly 2, yes 2 lines of code to maximize the window.
<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0 height=63 width=667><col style="border-right:1px solid gray;font-family:Courier New;font-size:11px;background-color:rgb(238, 238, 238);padding-right:5px;padding-left:10px;width:5px;color:gray;text-align:right;vertical-align:top <col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><nobr>1</nobr></td><td><font style="color:gray <font color="#3333ff #include <window.h>
<font color="#006600 //if using an older compiler, such as VS2003 or Dev Bloodshed</font>
</font></font><font color="#3333ff #define _WIN32_WINNT 0x500</font>
<font color="#006600 //Otherwise, ignore this #define statement</font>
<font style="color:gray ...
<font color="#3333ff int</font> <font color="#000000 main( )</font>
<font color="#000000 {
<font color="#006600 /******************************************
Here, we call the "ShowWindow" function, and pass it
the active window (Our program), and a constant meaning
"Maximize", as it is descriptively named.
*******************************************/</font>
</font><font color="#000000 ShowWindow( GetConsoleWindow() , SW_MAXIMIZE);</font>
...<font color="#3333ff
return</font> <font color="#000000 0;</font>
<font color="#000000 }</font>
</font><font style="font-size:11px
</font></td></tr></tbody></table>
That is all. No need to create a new screen buffer, no need to change to c# (powerful as it is, but who wants to rewrite all of their code?), and thankfully, no need to create objects which may or may not be supported. (I tried to create an HWND pointer and it said I couldnt do that.)
A side note: if youre working in an older compiler, like Dev Bloodshed 5.0 beta, or an older version of Visual Studio, make sure you put the #define statement. Otherwise, you dont need to, except maybe for clarity or backwards compatability.
View the full article
For all others who have run into this problem, if you are running XP or Vista, you can use exactly 2, yes 2 lines of code to maximize the window.
<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0 height=63 width=667><col style="border-right:1px solid gray;font-family:Courier New;font-size:11px;background-color:rgb(238, 238, 238);padding-right:5px;padding-left:10px;width:5px;color:gray;text-align:right;vertical-align:top <col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><nobr>1</nobr></td><td><font style="color:gray <font color="#3333ff #include <window.h>
<font color="#006600 //if using an older compiler, such as VS2003 or Dev Bloodshed</font>
</font></font><font color="#3333ff #define _WIN32_WINNT 0x500</font>
<font color="#006600 //Otherwise, ignore this #define statement</font>
<font style="color:gray ...
<font color="#3333ff int</font> <font color="#000000 main( )</font>
<font color="#000000 {
<font color="#006600 /******************************************
Here, we call the "ShowWindow" function, and pass it
the active window (Our program), and a constant meaning
"Maximize", as it is descriptively named.
*******************************************/</font>
</font><font color="#000000 ShowWindow( GetConsoleWindow() , SW_MAXIMIZE);</font>
...<font color="#3333ff
return</font> <font color="#000000 0;</font>
<font color="#000000 }</font>
</font><font style="font-size:11px
</font></td></tr></tbody></table>
That is all. No need to create a new screen buffer, no need to change to c# (powerful as it is, but who wants to rewrite all of their code?), and thankfully, no need to create objects which may or may not be supported. (I tried to create an HWND pointer and it said I couldnt do that.)
A side note: if youre working in an older compiler, like Dev Bloodshed 5.0 beta, or an older version of Visual Studio, make sure you put the #define statement. Otherwise, you dont need to, except maybe for clarity or backwards compatability.
View the full article