1619, 1/81 회원가입  로그인  
   U_SoRang
   http://root@root]# rm -rf /
   [펌+편집] [C언어] TEXT에 색을 입히자!! TEXT COLOR SET !!!

http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=1625 [복사]


#include <stdio.h>
#include <windows.h>     // 이 두 header file은 색을 입히기 위해 반드시 필요한 것입니다.

#define COL                   GetStdHandle(STD_OUTPUT_HANDLE)        // 콘솔창의 핸들정보 받기

#define BLACK                SetConsoleTextAttribute(COL, 0x0000);        // 검정색
#define DARK_BLUE         SetConsoleTextAttribute(COL, 0x0001);        // 파란색
#define GREEN                SetConsoleTextAttribute(COL, 0x0002);        // 녹색
#define BLUE_GREEN        SetConsoleTextAttribute(COL, 0x0003);        // 청녹색
#define BLOOD               SetConsoleTextAttribute(COL, 0x0004);        // 검붉은색
#define PURPLE               SetConsoleTextAttribute(COL, 0x0005);        // 보라색
#define GOLD                 SetConsoleTextAttribute(COL, 0x0006);        // 금색
#define ORIGINAL            SetConsoleTextAttribute(COL, 0x0007);        // 밝은 회색 (ORIGINAL CONSOLE COLOR)
#define GRAY                 SetConsoleTextAttribute(COL, 0x0008);        // 회색
#define BLUE                  SetConsoleTextAttribute(COL, 0x0009);        // 파란색
#define HIGH_GREEN       SetConsoleTextAttribute(COL, 0x000a);        // 연두색
#define SKY_BLUE           SetConsoleTextAttribute(COL, 0x000b);        // 하늘색
#define RED                   SetConsoleTextAttribute(COL, 0x000c);        // 빨간색
#define PLUM                SetConsoleTextAttribute(COL, 0x000d);        // 자주색
#define YELLOW             SetConsoleTextAttribute(COL, 0x000e);        // 노란색
#define WHITE                SetConsoleTextAttribute(COL, 0x000f);        // 흰색


★ Original로 되어 있는 색은 원래 console을 실행했을 때의 text color 입니다.


★ 색깔과 음영
    뒤에 있는 [0x000f]에서 끝의 두 자리가 color code 입니다.
    주의할 점은, 16진수로 되어 있기 때문에 { 0 ~ f } 까지만 넣으셔야 합니다.

    [          0          x          0          0          0          f          ]
                                                         음영색   글자색




끝 두 자리만 바꿔주면, source의 결과물을 화려하게 바꿀 수 있습니다.

  Hit : 20749     Date : 2010/12/15 05:54



    
VBora #include <windows.h> 헤더를 저런곳에도 사용할 수 있었군요;
올 좋은 정보 감사드립니다 ^^:
2010/12/15  
별빛을담아 windows.h를 잘 이용하면
비프음 연주도 가능하죠

어떤 잘난 친구 녀석이 프로그래밍시간에 자유연습을 가졌는데
비프음으로 눈의 꽃을 연주하더군요...
소감은.... 초라하지만 멋있어....
2010/12/16  
sinping 음... 활용은 어떻게 해야하나요? 활용방법좀... 예제라도.. 2010/12/26  
ganesha 별빛을담아 // 수업시간에 비프음 프로그래밍해서 연주한거 이어폰꽂고 감상하고 있었는데
모든 사람들이 절쳐다보더군요;;; 본체에서 소리났다내요 ㅋㅋㅋㅋㅋㅋ
2011/01/22  
rkdgh0112 아 숫자코드에서 여섯개 모두 색깔아닌가요?
각각 RGB 나타내는걸로 알고있는데 ..
2011/02/09  
rkdgh0112 아.. winapi에서의 색이였네 ㄷㄷ.
C코드로도 색 지정할수있는걸로 알고있는데.. 아닌가?
2011/02/09  
zades01 오 이런게 있네요 2022/12/14