码迷,mamicode.com
首页 > Windows程序 > 详细

window界面控制

时间:2018-07-26 23:40:09      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:pos   out   att   绿色   开始   rpo   namespace   gre   attribute   

一、挂起

#include<iostream>
#include<windows.h>
using namespace std;

int main() {
    for (int i = 10; i >= 0; i--) {
        system("cls");
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
        cout << "距离系统关闭还有:";
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
        cout << i << "" << endl;
        Sleep(1000);
    }
    return 0;
}

 

二、在屏幕随机输出

#include<iostream>
#include<windows.h>
using namespace std;

void gotoxy(int y, int x) {
    COORD pos;
    pos.X = x;
    pos.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}

int main() {
    gotoxy(8, 20);//从第5行 第20列开始输出
    cout << "欢迎来到信息管理系统,请求正在加载中...";
    for (int i = 0; i < 5; i++) {
        Sleep(1000);
        cout << "...";
    }
    cout << endl;
    return 0;
}

    

 

三、颜色控制

#include<iostream>
#include<windows.h>
using namespace std;

void main()
{
    cout << "原色" << endl;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);
    cout << "白色" << endl;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
    cout << "红色" << endl;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
    cout << "绿色" << endl;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
    cout << "蓝色" << endl;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
    cout << "黄色" << endl;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE);
    cout << "粉色" << endl;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |FOREGROUND_BLUE);
    cout << "青色" << endl;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
    cout << endl;
}

 

window界面控制

标签:pos   out   att   绿色   开始   rpo   namespace   gre   attribute   

原文地址:https://www.cnblogs.com/Gzu_zb/p/9374748.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!