|
|
 |
| C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
|
 |

June 10th, 2003, 02:23 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
gotoxy() in visual C++ 1.5
I am writing a DOS program that needs the gotoxy() function. Borland C++ has it in conio.h but VC++ does not have it. Since this is someone else's code, I can't change compiler.
Does someone have code sample to implement a gotoxy() function for cursor positioning?
Thanks
Carl
|

June 21st, 2003, 12:44 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Location: Colgate, WI, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Cursor positioning in text mode?
I believe you'll need to do some assembly work... plus Borland has an inline assembler.... I have a clue on how to do it in NASM, but not with C++ and inline ASM... sorry
|

June 23rd, 2003, 08:21 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Location: Goiania, GO, Brazil.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It's very simple to build a function like gotoxy() using a software interruption. The following code do this and it works fine in any compile running on DOS (like Turbo C and Visual C)
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void gotoxy (int x, int y)
{ union REGS regs;
regs.h.ah = 2; /* cursor position */
regs.h.dh = y;
regs.h.dl = x;
regs.h.bh = 0; /* vídeo page #0 */
int86(0x10, ®s, ®s);
}
int main (void)
{ clrscr();
movetoxy(35,10);
printf("Hello\n");
return 0;
}
Willians Santos
Software Engineer
Brazil
|

July 15th, 2003, 01:36 AM
|
|
Registered User
|
|
Join Date: Jul 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
#include <windows.h>
void gotoxy(int xpos, int ypos)
{
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
|

September 8th, 2004, 09:48 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hey guys... I tried the gotoxy(x, y) code you put out there and it doesnt work  . I have Microsoft Visual Studio .NET 2003 (Just in case that helps) and I am trying to make a program using gotoxy.
Thanx in advance for any new code.
Blaze!
|

March 22nd, 2006, 01:40 PM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Parabéns pela sua definição. Foi a mais objetiva e funcional que encontrei! Funcionou perfeitamente com o VC++ 6.0. Muitíssimo obrigado!!
Quote:
quote:Originally posted by pselva
#include <windows.h>
void gotoxy(int xpos, int ypos)
{
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
|
|

March 22nd, 2006, 01:47 PM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Parabéns pela sua definição. Foi a mais objetiva e funcional entre as que eu encontrei. Funcionou perfeitamente com o VC++ 6.0. Muitíssimo obrigado!
Quote:
quote:Originally posted by pselva
#include <windows.h>
void gotoxy(int xpos, int ypos)
{
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |