#### Archived

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

# translating coords and changing cursor position

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

## 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 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.

Worked, thanks!

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

• 12
• 15
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632656
• Total Posts
3007676
• ### Who's Online (See full list)

There are no registered users currently online

×