win32 console - form example!

Posted by Bach on Stack Overflow See other posts from Stack Overflow or by Bach
Published on 2010-05-30T02:36:57Z Indexed on 2010/05/30 2:42 UTC
Read the original article Hit count: 315

Filed under:

I'm trying to build a simple form in a c++ win32 console application. instead of using cin and keep prompting the user to enter the details, i would like to display the form labels then using the tab key, allow the user to tab through.

What is the simplest way of doing this, without having to use ncurses?

all I need is cout the below all at once:

Name:
Username:
Email:

set the cursor position next to name Field, then each time you hit tab, i gotoxy, and set the cursor at the next position, then set the the cin to the next variable eg. at startup

gotoxy(nameX, nameY);
cin >> name;

Hit Tab/enter

gotoxy(usernameX, usernameY);
cin >> username;

Hit Tab/enter

gotoxy(emailX, emailY);
cin >> email;

is this even doable?

I tried while loops with, GetAsyncKeyState, and keyboard events, but the cin is not working properly in that loop.

is there any good example for a super simple form, or reference for doing that? I know how to SetConsoleCursorPosition, but how to implement the tabbing while still being able to capture cin?

thanks

© Stack Overflow or respective owner

Related posts about c++