This section of the archives stores flipcode's complete Developer Toolbox collection, featuring a variety of mini-articles and source code contributions from our readers.

| More Console Fun Submitted by

Regarding the tip of the day called "Dynamic Win32 Console Allocation": You can change the color of the text you send to the console. This makes debugging via the console even more concise.
It is done by the Win32 API command

    BOOL SetConsoleTextAttribute(
      HANDLE hConsoleOutput,  // handle to console screen buffer
      WORD wAttributes        // text and background colors
    );

For example, to display a text in sunny yellow, you say:

    HANDLE stdout = GetStdHandle( STD_OUTPUT_HANDLE );
    SetConsoleTextAttribute(stdout, FOREGROUND_RED | FOREGROUND_GREEN |
    FOREGROUND_INTENSITY);
    printf("This is a yellow text.\n");

The following attributes are defined:
FOREGROUND_BLUE
FOREGROUND_GREEN
FOREGROUND_RED
FOREGROUND_INTENSITY
BACKGROUND_BLUE
BACKGROUND_GREEN
BACKGROUND_RED
BACKGROUND_INTENSITY
Kind regards
Armin Kaussner

The zip file viewer built into the Developer Toolbox made use of the zlib library, as well as the zlibdll source additions.

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.