|登录 |注册

查看: 1960|回复: 3
打印 上一主题 下一主题

programming c++如何跟换背景颜色~急急急

[复制链接]
myself
2011-11-14 11:42 PM
我是用code block写的c++,上网找了很多方法都试过了,目前只换到颜色,想请问下,背景色要怎么换,字体大小要怎么换,如何在里面加格子?


以下是我的coding,请高人指点指点
#include<iostream>
#include <windows.h>
using namespace std;

int main()

{
    textbackgroundcolor(5);
    textcolor(8+128);
    clrscr();

    HANDLE  hConsole;
   hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
   SetConsoleTextAttribute(hConsole,12);
   cout << "Your text here" << endl;


   return 0;
}

timmyw3i
2011-11-15 12:02 AM
你是說在 coding 裏面換 font 的大小 & background color???

這個好像不能的
Super-Tomato
2011-11-15 12:50 AM
我是用code block写的c++,上网找了很多方法都试过了,目前只换到颜色,想请问下,背景色要怎么换,字体大小要怎么换,如何在里面加格子?


以下是我的coding,请高人指点指点
#include<iostream>
#include <windows.h>
using namespace std;

int main()

{
    textbackgroundcolor(5);
    textcolor(8+128);
    clrscr();

    HANDLE  hConsole;
   hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
   SetConsoleTextAttribute(hConsole,12);
   cout << "Your text here" << endl;


   return 0;
}

myself 发表于 2011-11-14 11:42 PM


既然找到 SetConsoleTextAttribute 了就該去了解其參數用法而不是意味著能抄能行就好

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

  3. using namespace std;

  4. int main()
  5. {
  6.     HANDLE handler;

  7.     handler = GetStdHandle( STD_OUTPUT_HANDLE );
  8.     SetConsoleTextAttribute( handler, BACKGROUND_RED | FOREGROUND_GREEN );

  9.     cout << "Hello world!" << endl;
  10.     return 0;
  11. }
复制代码
myself
2011-11-15 04:29 PM
回复 3# Super-Tomato


    谢谢你,现在有点头绪了。
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2025-3-10 08:51 PM , Processed in 0.090311 second(s), 25 queries .

Powered by Discuz! X2.5 © 2001-2012 Comsenz Inc.

本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved

Dedicated Server powered by iCore Technology Sdn. Bhd.

合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部