首页 技术 正文
技术 2022年11月14日
0 收藏 639 点赞 3,199 浏览 1976 个字
知识点:
GetStdHandle函数
FillConsoleOutputCharacter函数
SetConsoleCursorPosition函数
system函数一、 GetStdHandle 获取标准设备句柄 :  
 HANDLE GetStdHandle(   DWORD nStdHandle   );  
 GetStdHandle()返回标准的输入、输出或错误的设备的句柄,也就是获得输入、输出/错误的屏幕缓冲区的句柄。  
 其参数nStdHandle的值为下面几种类型的一种:  
 值含义  
 STD_INPUT_HANDLE 标准输入的句柄  
 STD_OUTPUT_HANDLE 标准输出的句柄   
STD_ERROR_HANDLE 标准错误的句柄
二、FillConsoleOutputCharacter 填充字符
BOOL FillConsoleOutputCharacter(HANDLE hConsoleOutput, // 缓冲区句柄 一般通过
GetStdHandle(STD_OUTPUT_HANDLE)获取
TCHAR cCharacter, // 要填充的字符
DWORD nLength, // 填充的字符数量
COORD dwWriteCoord, // 填充的起始坐标x,y
LPDWORD lpNumberOfCharsWritten
// 返回一个写入数量的指针 );三、SetConsoleCursorPosition 移动光标位置
BOOL SetConsoleCursorPosition( HANDLE hConsoleOutput, //缓冲区句柄 一般通过
GetStdHandle(STD_OUTPUT_HANDLE)获取 COORD dwCursorPosition // 指定新的光标位置
);四、设置当前光标位置 gotoxy(int x, int y);
//之前需要用字符填满窗口缓冲区
、获取当前输出缓冲区句柄 GetStdHandle
、设置当前光标位置(x,y) SetConsoleCursorPosition五、用system命令设置颜色和标题
system("title 郁金香灬老师:QQ150330575"); //设置标题
system("color 0A"); //设置颜色
六、绘制方框
、确定左上角坐标X,Y //画边前先用空格填满窗口缓冲区
、画上边
、画下边
、画左边
、下右边作业:
A、探讨以下2个控制台函数的使用方法:
、GetConsoleTitle 获取控制台窗口标题
、SetConsoleTitle 设置控制台窗口标题
B、绘制一个2*2的表格 : 类似下图#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <time.h>
#include "hello.h"
#include <share.h>
#include <Windows.h>//清屏
void cls_screen(char a)
{
COORD xy={,};
long byw;
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
FillConsoleOutputCharacter(hout,a,,xy,&byw);
}
//#define var 333;
void gotoxy(int x,int y)
{
COORD xy={,}; HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
xy.X=x;
xy.Y=y;
SetConsoleCursorPosition(hout,xy);
}
//绘制方框
#define X 22
#define Y 6
void drawM(void)
{ int i,j;
//到达x,y
gotoxy(X,Y);
//上边--------------------
printf("┏");
for (i=;i<=;i++)
{
printf("━");
}
printf("┓");
//左边 for (i=;i<;i++)
{
gotoxy(X,Y++i);
printf("┃");
}
//右边 for (i=;i<;i++)
{
gotoxy(X+,Y++i);
printf("┃");
}
//下边
gotoxy(X,Y+);
//上边--------------------
printf("┗");
for (i=;i<=;i++)
{
printf("━");
}
printf("┛");}
int main(void)
{ system("title QQ150330575");
system("color 0a");
system("dir");
cls_screen(' ');//清屏;
cls_screen(' ');//;
gotoxy(,);
//绘制方框
drawM();
getchar();
getchar();
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,967
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,487
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,332
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,115
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,748
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,783