Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading the cursor x y pos in a console window 1

Status
Not open for further replies.

waynejfoster

Programmer
Aug 7, 2001
13
0
0
GB
I've got a console window open in windows xp. I can set the cursor x y position, but I can't read the current x y position. How do I read the cursor x,y pos.

Here is the code to set the cursor x,y pos.

The only function I have seen is GetConsoleCursorInfo but this just returns the size,visibility.

/
// Moves the cursor to x, y in console window
// ie x=left\right y=top\bottom
//
void set_cursor_xy(int x, int y)
{
COORD point;
if((x < 0 || x > screensize.x) || (y < 0 || y > screensize.y))
return;
point.X = x; point.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), point);
}
 
call GetConsoleScreenBufferInfo. The returned CONSOLE_SCREEN_BUFFER_INFO structure contains the cursor position.



Marcel
 
You may also use interruption 33h, __asm int 33h

Ion Filipski
1c.bmp
 
>B00gyeMan
I've taken a look at your link and liked it a lot :)

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top