[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CCursor

(C) Cursor

Setting the cursor position

Here is a small program that can change the position of the cursor, to anywhere on the screen.

The coordinates is set like this:
        cursor_coord.X=(40-(strlen(buffer)/2));
	cursor_coord.Y=12.5;


In this code the coordinates is set to (40,12.5).

  1. include <windows.h>
int main() { HANDLE console_handle; COORD cursor_coord; char *buffer = "Cursor Position: (40,12.5)"; DWORD actual=0; cursor_coord.X=(40-(strlen(buffer)/2)); cursor_coord.Y=12.5; console_handle= GetStdHandle( STD_OUTPUT_HANDLE); if (SetConsoleCursorPosition(console_handle,cursor_coord)) WriteConsole(console_handle,buffer,strlen(buffer),&actual,NULL); }


Code links



last edited (March 3, 2007) by bilderbikkel, Number of views: 609, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.