ReadConsoleOutput changes the size of my SMALL_RECT... help!

E

Eric A. Johnson

Hello All,

I'm having a problem with the below code. I am trying to copy an area
of screen space into an X by Y array of type CHAR_INFO before I overwrite it
with my "window". If I comment out the line that uses ReadConsoleOutput to
copy the screen area, the SMALL_RECT (WindowRectangle) is unchanged, and the
window displays just fine. However, if I uncomment it, it changes
WindowRectangle's dimensions to a much smaller size, resulting in a smaller
(or even nonexistant) window. How do I fix this? I'm at my wit's end.
Below is the relevant code. If somebody needs more or all of the source, I
will gladly post it -- just let me know. Thanks!

Sincerely,

Eric

/* Create a new window */
void ConsoleLib::WindowCreate(COORD Start, COORD Size, bool Border)
{
int column, row;
SMALL_RECT WindowRectangle;
COORD Position;
/*... more unrelated code here ...*/

// Make an array (buffer) to hold the screen info I will overwrite
CharInfo = new CHAR_INFO[Size.X, Size.Y];

// Save the screen information that will be overwritten into CharInfo
/*** NOTE: The line below is strangely altering WindowRectangle ***/
// ReadConsoleOutput(m_Screen, CharInfo, Size, Start, &WindowRectangle);

}

Notes: m_Screen is a handle to the console; CharInfo has been previously
declared as a pointer to CHAR_INFO; Border simply declares whether the
window has a visible border or not. I make all the important changes to
Size before declaring the new CharInfo array. Start is not changed at all.
It's still starting at the same position; it simply ends both the length and
width before it should. I am using the WindowRectangle borders to control
the display of the Window, to encertain that the information it saves is the
same as what is written over. I want to be able to replace the original
information when the window is destroyed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,662
Latest member
sxarexu

Latest Threads

Top