Archived

This topic is now archived and is closed to further replies.

translating coords and changing cursor position

This topic is 5870 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all. I am using FillOutputAttributeCharacter to write to specific coords in the console program I am making (using C++), but I''d like to take coord (0,0) for example and translate to (40,5). Then (1,0) would be (41,5) etc... How would I go about doing this translation? My second question is in regards to cursor position in the DOS console window. I have a 10x10 grid of colors that I don''t want the user to be able to type on. How would I make sure they don''t type on this grid? I know how to use SetConsoleCursorPosition(..) to change where the cursor is placed, but I need to do this. Oh yeah, somehow couldn''t I just make a rectangle on the screen where they can type or something similar? Thanks everyone :D

Share this post


Link to post
Share on other sites
quote:
Original post by randomDecay
...I''d like to take coord (0,0) for example and translate to (40,5). Then (1,0) would be (41,5) etc...
How would I go about doing this translation?

Write a wrapper function:
BOOL SetMyConsoleCursorPosition(HANDLE hConsoleOutput, int x, int y)
{
COORD C;
C.X = x + 40;
C.Y = y;
return SetConsoleCursorPosition(hConsoleOutput, C);
}


quote:
...I know how to use SetConsoleCursorPosition(..) to change where the cursor is placed, but I need to do this.

Use SetConsoleCursorPosition(). There''s no "easy way out."

quote:
Oh yeah, somehow couldn''t I just make a rectangle on the screen where they can type or something similar?

There''s no Win32 API console function to define viewports.

Share this post


Link to post
Share on other sites