different text in console

This is a discussion on different text in console within the C++ Programming forums, part of the General Programming Boards category; am working on a win32 console app (Dos style) and am trying to switch up my text for a men. ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    18

    different text in console

    am working on a win32 console app (Dos style) and am trying to switch up my text for a men. Maybe instead of black background, white text, maybe white background and black text. Or even just another color text. any idea. I know Basic could do it, you gotta figure c++ can...

    thanks all.
    cow

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    reply


    Syntax

    #include <conio.h>
    void textcolor(int newcolor);

    Description

    Selects new character color in text mode.

    Note: Do not use this function for Win32s or Win32 GUI applications.

    textcolor selects the foreground character color. This function works for the console output functions. newcolor selects the new foreground color. You can set newcolor to an integer as given in the table below, or to one of the symbolic constants defined in conio.h. If you use symbolic constants, you must include conio.h.
    Once you have called textcolor, all subsequent functions using direct video output (such as cprintf) will use newcolor. textcolor does not affect any characters currently onscreen.


    Syntax

    #include <conio.h>
    void textbackground(int newcolor);

    Description

    Selects new text background color.

    Note: Do not use this function for Win32s or Win32 GUI applications.

    textbackground selects the background color. This function works for functions that produce output in text mode directly to the screen. newcolor selects the new background color. You can set newcolor to an integer from 0 to 7, or to one of the symbolic constants defined in conio.h. If you use symbolic constants, you must include conio.h.
    Once you have called textbackground, all subsequent functions using direct video output (such as cprintf) will use newcolor. textbackground does not affect any characters currently onscreen.

    Borland C++ 5.0 Programmer's Guide
    You use cprintf() to print out coloured text.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    with basic you are programming in 100% DOS, with C++ you are programming in a win32 Console.

    I dont think you can change the background of the console but u can change the foreground and background of the text.

    you have to include stdio.h or stdlib.h, i cant remember which one.

    Code:
    HANDLE hStdout;
    hStdout = GetStdHandle(STD_OUTPUT_HANDLE); // Put this at the top of your code
    
    SetConsoleTextAttribute(hStdout,BACKGROUND_RED|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); //This will give you White on RED
    this is one of the ways

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    18

    looks like it would work

    but have used that code, and i am getting errors around it.

    saying missing a ; prior to the handle line.

    and i supposed to replace handle with something??

    thanks
    cow

  5. #5
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    go here and read something i wrote...

    +++
    ++
    + Sekti
    ++
    +++

  6. #6
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >go here and read something i wrote...

    Your title "C++ Standard i/o" needs the word Standard removing.

    >and i supposed to replace handle with something??

    No you probably have to include windows.h.

  7. #7
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    its standard

    its standard as in the basics hence standard your thinking to far ahead
    +++
    ++
    + Sekti
    ++
    +++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 01:23 AM
  2. Text Enhancement from DOS console
    By 3DMatrix in forum C++ Programming
    Replies: 8
    Last Post: 06-06-2004, 09:12 AM
  3. mygets
    By Dave_Sinkula in forum C Programming
    Replies: 6
    Last Post: 03-23-2003, 07:23 PM
  4. console text colors??
    By Agent89 in forum C++ Programming
    Replies: 5
    Last Post: 05-24-2002, 11:08 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21