SHARE
TWEET

conColorEx.c

Phr0zen_Penguin Nov 23rd, 2013 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*============================================================================
  2.   ----------------------------------------------------------------------------
  3.   conColorEx.c - Console 'text' coloring example.
  4.                  (c) Damion 'Phr0z3n.Dev' Tapper, 2013.
  5.                  Email: Phr0z3n.Dev@Gmail.com
  6.  
  7.   NOTE: Save 'myColor.h' in the same location as this file.
  8.   ----------------------------------------------------------------------------
  9.   ============================================================================*/
  10. #define USE_SEC_API /* Comment this line if you do not have the secure libraries. */
  11.  
  12. #include <stdio.h>
  13. #include <windows.h> /* For console coloring/manipulation functions. */
  14. #include "mycolor.h" /* For predefined color values. */
  15.  
  16. int main(void)
  17. {
  18. #ifdef USE_SEC_API
  19.         /* Predefined 'color-on-color' application. */
  20.         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), INTENSE_YELLOW_ON_BLUE);
  21.         printf_s("Hello"); /* The secure printf function (good programming practice). */
  22.  
  23.         /* Bitwise predefined 'foreground-on-background' application. */
  24.         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_INTENSE_WHITE | FOREGROUND_INTENSE_MAGENTA);
  25.         printf_s("'Unboring'");
  26.  
  27.         /* Bitwise predefined abbreviated 'foreground-on-background' application. */
  28.         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), B_RED | F_INTENSE_BLUE);
  29.         printf_s("World!");
  30. #else
  31.         /* If you are lacking the secure libraries. */
  32.         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), INTENSE_YELLOW_ON_BLUE);
  33.         printf("Hello");
  34.  
  35.         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_INTENSE_WHITE | FOREGROUND_INTENSE_MAGENTA);
  36.         printf("'Unboring'");
  37.  
  38.         SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), B_RED | F_INTENSE_BLUE);
  39.         printf("World!");
  40. #endif
  41.  
  42.         return 0;
  43. }
RAW Paste Data
Top