C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
console cursor postition Posted by rickrat on 14 Oct 2005 at 1:45 PM
Hi, I'm trying to move the cursor (not mouse cursor) within the console window. As I understand I can use a function in conio.h called gotoxy(). I cant get this to work. Does anyone know how I can move the cursor so I can print text anyware in the console window I want.

I would really like to print a menu of options and above that, I would like the user to enter their selection.

And I DONT want to use MFC or anything that calls windows.h

Right now, I'm using Dev-C++ 4 as a compiler.

~Eric
Report
Re: console cursor postition Posted by DB1 on 14 Oct 2005 at 3:56 PM
: Hi, I'm trying to move the cursor (not mouse cursor) within the console window. As I understand I can use a function in conio.h called gotoxy(). I cant get this to work. Does anyone know how I can move the cursor so I can print text anyware in the console window I want.
:
: I would really like to print a menu of options and above that, I would like the user to enter their selection.
:
: And I DONT want to use MFC or anything that calls windows.h
:
: Right now, I'm using Dev-C++ 4 as a compiler.
:
: ~Eric
:

Well guess what, there is no way to do things like that in standard C/C++.

You're working on Windows so there's nothing wrong with using windows.h and other windows specific header files to do your console manipulations.

If you're trying to write a cross-platform program then you'll need to either use OS specific code for each platform's build or you'll need to use a cross-platform library that does what you need.





To understand recursive, first you need to understand recursive

Report
Re: console cursor postition Posted by Gregry2 on 15 Oct 2005 at 2:55 AM
: : Hi, I'm trying to move the cursor (not mouse cursor) within the console window. As I understand I can use a function in conio.h called gotoxy(). I cant get this to work. Does anyone know how I can move the cursor so I can print text anyware in the console window I want.
: :
: : I would really like to print a menu of options and above that, I would like the user to enter their selection.
: :
: : And I DONT want to use MFC or anything that calls windows.h
: :
: : Right now, I'm using Dev-C++ 4 as a compiler.
: :
: : ~Eric
: :
:
: Well guess what, there is no way to do things like that in standard C/C++.
:
: You're working on Windows so there's nothing wrong with using windows.h and other windows specific header files to do your console manipulations.
:
: If you're trying to write a cross-platform program then you'll need to either use OS specific code for each platform's build or you'll need to use a cross-platform library that does what you need.
:
:
:
:
:
: To understand recursive, first you need to understand recursive

or you could work around wiht fancy macros

#define a macro like changeCursor(x,y)
and make it a wrapper(is that correct terminology?)

#define changeCursor(x,y) \
winchangecur(x,y)


winchangecur is the real function(or macro, i dont think you need a function for that)

then use only changeCursor in ur code, but as u port the program, write a new function and place it there in changeCursor's definition instead of winchangcur

by the way, i would like to know how you do that using only the API, not MFC, non C++

thanx you two
{2}rIng
Report
Re: console cursor postition Posted by DB1 on 15 Oct 2005 at 3:53 AM
: : : Hi, I'm trying to move the cursor (not mouse cursor) within the console window. As I understand I can use a function in conio.h called gotoxy(). I cant get this to work. Does anyone know how I can move the cursor so I can print text anyware in the console window I want.
: : :
: : : I would really like to print a menu of options and above that, I would like the user to enter their selection.
: : :
: : : And I DONT want to use MFC or anything that calls windows.h
: : :
: : : Right now, I'm using Dev-C++ 4 as a compiler.
: : :
: : : ~Eric
: : :
: :
: : Well guess what, there is no way to do things like that in standard C/C++.
: :
: : You're working on Windows so there's nothing wrong with using windows.h and other windows specific header files to do your console manipulations.
: :
: : If you're trying to write a cross-platform program then you'll need to either use OS specific code for each platform's build or you'll need to use a cross-platform library that does what you need.
: :
: :
: :
: :
: :
: : To understand recursive, first you need to understand recursive
:
: or you could work around wiht fancy macros
:
: #define a macro like changeCursor(x,y)
: and make it a wrapper(is that correct terminology?)
:
:
: #define changeCursor(x,y) \
: winchangecur(x,y)
: 

:
: winchangecur is the real function(or macro, i dont think you need a function for that)
:
: then use only changeCursor in ur code, but as u port the program, write a new function and place it there in changeCursor's definition instead of winchangcur
:
: by the way, i would like to know how you do that using only the API, not MFC, non C++
:
: thanx you two
: {2}rIng
:


Using macros to wrap OS specific code is the same as what I already mentioned when I said "use OS specific code for each platform's build"


For Windows, look for SetConsoleCursorPosition()
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/console_functions.asp

To understand recursive, first you need to understand recursive

Report
Re: console cursor postition Posted by kern68 on 15 Oct 2005 at 9:38 AM
: : : : Hi, I'm trying to move the cursor (not mouse cursor) within the console window. As I understand I can use a function in conio.h called gotoxy(). I cant get this to work. Does anyone know how I can move the cursor so I can print text anyware in the console window I want.
: : : :
: : : : I would really like to print a menu of options and above that, I would like the user to enter their selection.
: : : :
: : : : And I DONT want to use MFC or anything that calls windows.h
: : : :
: : : : Right now, I'm using Dev-C++ 4 as a compiler.
: : : :
: : : : ~Eric
: : : :
: : :
: : : Well guess what, there is no way to do things like that in standard C/C++.
: : :
: : : You're working on Windows so there's nothing wrong with using windows.h and other windows specific header files to do your console manipulations.
: : :
: : : If you're trying to write a cross-platform program then you'll need to either use OS specific code for each platform's build or you'll need to use a cross-platform library that does what you need.
: : :
: : :
: : :
: : :
: : :
: : : To understand recursive, first you need to understand recursive
: :
: : or you could work around wiht fancy macros
: :
: : #define a macro like changeCursor(x,y)
: : and make it a wrapper(is that correct terminology?)
: :
: :
: : #define changeCursor(x,y) \
: : winchangecur(x,y)
: : 

: :
: : winchangecur is the real function(or macro, i dont think you need a function for that)
: :
: : then use only changeCursor in ur code, but as u port the program, write a new function and place it there in changeCursor's definition instead of winchangcur
: :
: : by the way, i would like to know how you do that using only the API, not MFC, non C++
: :
: : thanx you two
: : {2}rIng
: :
:
:
: Using macros to wrap OS specific code is the same as what I already mentioned when I said "use OS specific code for each platform's build"
:
:
: For Windows, look for SetConsoleCursorPosition()
: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/console_functions.asp
:
: To understand recursive, first you need to understand recursive
:
:
Here is a good site with tutes on console windows:

http://www.adrianxw.dk/SoftwareSite/index.html
Report
Re: console cursor postition Posted by rickrat on 15 Oct 2005 at 10:20 AM
wow, this site is really cool: http://www.adrianxw.dk/SoftwareSite/index.html thanks for all the information. i didnt realize there was a windows.h file that comes with dev-c++. i really like that site b/c it allows you to draw things on a console window.

thanks everyone!
Eric



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - 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 our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.