I am coding a display class and i have no idea how to do this as we did not do it in school, but it's required in the assignment -
the constructor of the class is supposed to define the area on the dos window, starting from the fifth row, and the height of the display area is ten rows, so when an arrow is pressed - up or down - the display goes thru an array of String objects, displaying 10 strings.
so:
DOS WINDOW:
++++++++++++++++++++
+ 5 ROWS
+
+++++++++++++++++++++
+DISPLAY AREA
+IS 10 ROWS
+HIGH
+
++++++++++++++++++++++
+REST OF DOS WINDOW,
+UNUSED
+
+++++++++++++++++++++
what i was thinking about doing is, eact time a button is pressed
the screen is cleared, then SetConsoleCursorPosition sets to the 5th row,
and 10 rows are displayed - for i=n to n+10, where n is decremented or incremented depending on the arrow pressed
so first n is 0, first 10 rows are displayed, down row is pressed, screen is cleared and n++, so n = i = 1, so the second to 11th rows are diplayed
but i would rather do it by the assignment specs, where the display area is defined once in the constructor 'n stuff
Just an idea,
Could u have a couple private member vars like
1 2
int rowStart;
int heightMax;
Then in the constructor u can set those variables.
Then whenever u want to clear the screen just call something like:
1 2 3 4 5 6 7
PrintDisplay()
{
//print as many lines as the heightMax variable allows
SetConsoleCursorPosition // based on the value in rowStart
GetConsoleWindow //u might need this too...
GetWindowRect //and this one...just in case
}
U may want to split that PrintDisplay into 2 funcs namely: ClearDisplay() and PrintDisplay() but that's the general idea...