Archived

This topic is now archived and is closed to further replies.

The_wow

gotoxy or something in VC++

Recommended Posts

gotoxy is function in Borland C++. It changes cursor position in dos promt. I want to do the same thing in Visual C++. The only function what I found was SetConsoleCursorPosition. Well, it seems ok but it doesn''t work! I have included its header windows.h and I have added its library kernel32.lib but when I try to link my little program it says: Console.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) int __stdcall SetConsoleCursorPosition(void *,struct _COORD)" (__imp_?SetConsoleCursorPosition@@YGHPAXU_COORD@@@Z) Have anybody succesfully used SetConsoleCursorPosition? I have win98SE and Visual Studio 6.0 with newiest Service Packs. Is there some another way?? Please help me!

Share this post


Link to post
Share on other sites
SetConsoleCursorPosition

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in wincon.h.
Import Library: Use kernel32.lib.

That is from MSDN.
I have declared wincon.h and I have added kernel32.lib to right place. It should work..

Share this post


Link to post
Share on other sites
This took less than 2 minutes;

1. Make a new project; an empty Win32 console application.
2. Create a new C++ source file, and paste this code into it:

  
#include <windows.h>
#include <iostream.h>

void main(void)
{
COORD pos;
pos.X = 20; pos.Y = 10;
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), pos);

cout << "This works fine!" << endl;
}


I''d check you are actually working with a console project and not a lib,dll or Win32 app.

- Matt



Share this post


Link to post
Share on other sites
I tried that and it''s almost the same what I have already tried..
Sorry but it doesn''t work with my computer.. Now I''m sure that there is something wrong with this machine..

I''l try install Visual Studio again..

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
by putting the lib in the right place do you mean you added it specifically to this project or just that it is in your include place? You probably have this right but other people will read this thread and this really bothered me as a newbie. Go to project-settings-link-object/library modules and add whatever libraries you need there.

Share this post


Link to post
Share on other sites
Yes. kernel32.lib is in there Object/Library modules and it''s also in project options.
Well.. I have Borland C++ now and I tried gotoxy with that (same thing as SetConsoleCursorPosition).. It works great, and I''m thinking to change Borland C++.. I have used Borland Delphi and Turbo Pascal so I think this is much easier to me than Visual C++.. I''m still doing all DirectX stuff with Visual C++..
Thanks everybody who helped me!

Share this post


Link to post
Share on other sites