控制台要怎样制作一个选项框

 我来答
lilipat
高粉答主

2017-07-13 · 每个回答都超有意思的
知道大有可为答主
回答量:3万
采纳率:94%
帮助的人:5037万
展开全部
请问控制台要怎样制作一个选项框
RT~想制作一个像这样的选项框
+++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++
++ ++
++ ---->确定 ++
++ ++
++ ++
++ ++
++ 取消 ++
++ ++
++ ++
+++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++
上面的箭头可以通过键盘的上下来移动~~
不想用cout一个个输出,想自己写一个函数以后如果里面的字(字数不固定)要改的话可以直接调用,请问要怎么做呀??希望大家指教~~
昵称: shimizuly 时间: 2010-08-18 14:16:39
额怎么看不明白……
昵称: yzx714 时间: 2010-08-18 14:18:37
+++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++
++ ++
++ ---->确定 ++
++ ++
++ ++
++ ++
++ 取消 ++
++ ++
++ ++
+++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++
昵称: shimizuly 时间: 2010-08-18 14:22:28
C/C++ code

+++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++
++ ++
++ ---->确定 ++
++ ++
++ ++
++ ++
++ 取消 ++
++ ++
++ ++
+++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++

昵称: shimizuly 时间: 2010-08-18 14:24:49
引用 1 楼 yzx714 的回复:

额怎么看不明白……

请问猴子头像怎么发出来的?点哪里?
昵称: hastings 时间: 2010-08-18 14:26:20

哪里看不懂呀??
昵称: shimizuly 时间: 2010-08-18 14:36:17

一楼的图没贴好,看到3楼我明白了
昵称: yzx714 时间: 2010-08-18 14:46:38
C/C++ code
while(true)
{
char a = getch();
switch(a)
{
case UP:
Up();
break;
case DOWN:
Down();
break;
}
ClearConsole();
DrawMenu();
DrawCursor();
}

以前都是用类似这样的方式作耶.....
要储存现在选了哪一个....
#include <conio.h>
这里面有很多东西可以使用....
gotoxy可以移动游标的位置...这个很好用....
cprintf可以输出有颜色的文字....
以前是用TurboC++3.0玩这些东西...
不过已经是9年前的事情了....
代码不知道还找不找的到...
昵称: cloudhsu 时间: 2010-08-18 15:00:11
楼主与时俱进吧,用用图形界面程序吧。
昵称: taodm 时间: 2010-08-18 15:01:39
用控制台写这个东西,,哈哈,,楼主v5啦。
昵称: genlic 时间: 2010-08-18 15:20:41
引用 7 楼 cloudhsu 的回复:
C/C++ code
while(true)
{
char a = getch();
switch(a)
{
case UP:
Up();
break;
case DOWN:
Down();
break;
}
ClearConsole();
DrawMenu();……

能讲得具体些么??
昵称: shimizuly 时间: 2010-08-18 16:01:42
http://blog.csdn.net/cloudhsu/archive/2010/08/18/5822338.aspx
参考这篇吧....
不过建议你下载执行看看.....
里面的一些乱码,当初是使用ASCII在16位元编译环境弄的
昵称: cloudhsu 时间: 2010-08-18 22:07:49
参考这个

C/C++ code
#include <windows.h>
#include <stdio.h>

void ConPrint(char *CharBuffer, int len);
void ConPrintAt(int x, int y, char *CharBuffer, int len);
void gotoXY(int x, int y);
void ClearConsole(void);
void ClearConsoleToColors(int ForgC, int BackC);
void SetColorAndBackground(int ForgC, int BackC);
void SetColor(int ForgC);
void HideTheCursor(void);
void ShowTheCursor(void);

int main(int argc, char* argv[])
{
HideTheCursor();
ClearConsoleToColors(15, 1);
ClearConsole();
gotoXY(1, 1);
SetColor(14);
printf("This is a test...\n");
Sleep(500);
ShowTheCursor();
SetColorAndBackground(15, 12);
ConPrint("This is also a test...\n", 23);
SetColorAndBackground(1, 7);
ConPrintAt(22, 15, "This is also a test...\n", 23);
gotoXY(0, 24);
SetColorAndBackground(7, 1);
return 0;
}

//This will clear the console while setting the forground and
//background colors.
void ClearConsoleToColors(int ForgC, int BackC)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
//Get the handle to the current output buffer...
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
//This is used to reset the carat/cursor to the top left.
COORD coord = {0, 0};
//A return value... indicating how many chars were written
//not used but we need to capture this since it will be
//written anyway (passing NULL causes an access violation).
DWORD count;

//This is a structure containing all of the console info
// it is used here to find the size of the console.
CONSOLE_SCREEN_BUFFER_INFO csbi;
//Here we will set the current color
SetConsoleTextAttribute(hStdOut, wColor);
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
//This fills the buffer with a given character (in this case 32=space).
FillConsoleOutputCharacter(hStdOut, (TCHAR) 32, csbi.dwSize.X * csbi.dwSize.Y, coord, &count);

FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
//This will set our cursor position for the next print statement.
SetConsoleCursorPosition(hStdOut, coord);
}
}

//This will clear the console.
void ClearConsole()
{
//Get the handle to the current output buffer...
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
//This is used to reset the carat/cursor to the top left.
COORD coord = {0, 0};
//A return value... indicating how many chars were written
// not used but we need to capture this since it will be
// written anyway (passing NULL causes an access violation).
DWORD count;
//This is a structure containing all of the console info
// it is used here to find the size of the console.
CONSOLE_SCREEN_BUFFER_INFO csbi;
//Here we will set the current color
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
//This fills the buffer with a given character (in this case 32=space).
FillConsoleOutputCharacter(hStdOut, (TCHAR) 32, csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
//This will set our cursor position for the next print statement.
SetConsoleCursorPosition(hStdOut, coord);
}
}

//This will set the position of the cursor
void gotoXY(int x, int y)
{
//Initialize the coordinates
COORD coord = {x, y};
//Set the position
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

//This will set the forground color for printing in a console window.
void SetColor(int ForgC)
{
WORD wColor;
//We will need this handle to get the current background attribute
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;

//We use csbi for the wAttributes word.
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
//Mask out all but the background attribute, and add in the forgournd color
wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
SetConsoleTextAttribute(hStdOut, wColor);
}
}

//This will set the forground and background color for printing in a console window.
void SetColorAndBackground(int ForgC, int BackC)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}

//Direct console output
void ConPrint(char *CharBuffer, int len)
{
DWORD count;
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), CharBuffer, len, &count, NULL);
}

//Direct Console output at a particular coordinate.
void ConPrintAt(int x, int y, char *CharBuffer, int len)
{
DWORD count;
COORD coord = {x, y};
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hStdOut, coord);
WriteConsole(hStdOut, CharBuffer, len, &count, NULL);
}

//Hides the console cursor
void HideTheCursor()
{
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

if(GetConsoleCursorInfo(hStdOut, &cciCursor))
{
cciCursor.bVisible = FALSE;
}
}

//Shows the console cursor
void ShowTheCursor()
{
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

if(GetConsoleCursorInfo(hStdOut, &cciCursor))
{
cciCursor.bVisible = TRUE;
}
}

作者昵称: zhao4zhong1 时间: 2010-08-18 23:34:50
杭州励贝电液科技有限公司
2023-08-23 广告
设计比例控制器需要以下步骤:1. 确定控制系统的要求,例如控制对象的特性、控制范围、精度等。2. 选择合适的传感器,能够准确测量控制对象的相关参数,例如位置、速度、压力等。3. 选择合适的执行器,能够产生足够的控制作用,例如电缸、电动推杆等... 点击进入详情页
本回答由杭州励贝电液科技有限公司提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式