p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

Free Code from Wrox
Go Back   p2p.wrox.com Forums > C# and C > C++ and Visual C++ > C++ Programming
I forgot my password
Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 10th, 2003, 02:23 PM
Authorized User
Points: 61, Level: 1
Points: 61, Level: 1 Points: 61, Level: 1 Points: 61, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 21st, 2003, 12:44 PM
Authorized User
Points: 38, Level: 1
Points: 38, Level: 1 Points: 38, Level: 1 Points: 38, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Colgate, WI, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Ammiel Send a message via AIM to Ammiel Send a message via MSN to Ammiel
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old June 23rd, 2003, 08:21 AM
Registered User
Points: 2, Level: 1
Points: 2, Level: 1 Points: 2, Level: 1 Points: 2, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Goiania, GO, Brazil.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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, &regs, &regs);
}

int main (void)
{ clrscr();
   movetoxy(35,10);
   printf("Hello\n");
   return 0;
}



Willians Santos
Software Engineer
Brazil
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 15th, 2003, 01:36 AM
Registered User
Points: 2, Level: 1
Points: 2, Level: 1 Points: 2, Level: 1 Points: 2, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pselva
Default

#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);
}


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old September 8th, 2004, 09:48 PM
Registered User
Points: 2, Level: 1
Points: 2, Level: 1 Points: 2, Level: 1 Points: 2, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old March 22nd, 2006, 01:40 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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);
}


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old March 22nd, 2006, 01:47 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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);
}


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio VS. Visual Web Developer expr Astrocloud BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 November 23rd, 2008 03:10 PM
diffrece between Visual C# & Visual C++ vinu123 C# 2005 3 December 18th, 2006 08:07 AM
FTP in Visual Studio 2005 Pro (Visual Basic) shoopes VB How-To 1 June 29th, 2006 03:08 PM
Crystal Reports in Visual St 2002 vs Visual St2003 Tatanka Crystal Reports 0 August 23rd, 2004 11:23 AM
How do I use Visual studio for Visual C++ kevin777 Visual C++ 1 October 24th, 2003 10:21 AM



All times are GMT -4. The time now is 08:09 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2010 Wiley Publishing, Inc