Thread: A question regarding command prompt's look

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    36

    A question regarding command prompt's look

    I know already that you can change cmd's background and font color by doing:

    Code:
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
            system("color 17");
            cout<<"This prints me gray on a blue background.";
            cin.get();
    }
    But is it possible to instead of changing cmd's background to a different color, can you instead make it display a background picture somehow?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Not trivially. The colours and stuff drawn by the command prompt is controlled by a system process (it may seem like you are writing "directly" to the command prompts console window, but there is actually another process in the system that manages the drawing of the console window). You could, possibly, write a replacement system process - but it's far from an entirely trivial task.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Instead of dressing up a console, perhaps you should look into real graphical user interfaces that most user applications use. A console application is mostly about getting a job done, not about being eye-candy

    BTW, your code doesn't use anything from <windows.h> (there are functions to set console text attributes) but just lets an external program do the job.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I believe there is a good tutorial by adrianxw that addresses more complex changing of console colors and stuff like that, but I doubt you could put an actual picture in the background. If changing colors and other attributes is enough try searching google for adrianxw and you might find enough information to do what you're trying to do.

  5. #5
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163
    The console resolution is too small to put a good picture, but it can be done with functions from wincon.h.
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    36
    Quote Originally Posted by anon View Post
    ...Perhaps you should look into real graphical user interfaces that most user applications use...
    Where could I see a tutorial that would help you make such program?

  7. #7
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163
    Learn to search, people. It gives better results than doing nothing. There are hundrends of tutorials about this on the web, use Google to learn and MSDN as a reference.
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

  8. #8
    Registered User
    Join Date
    Nov 2008
    Posts
    36
    Quote Originally Posted by hauzer View Post
    Learn to search, people. It gives better results than doing nothing. There are hundrends of tutorials about this on the web, use Google to learn and MSDN as a reference.
    Ok, I found the program here: ftp://ftp.gtk.org/pub/gtk/2.14/

    But what can't figure out is how to install it. Help?

  9. #9
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    err how much C++ do you know?

    If you can't even figure out how to install it, you are not ready for it (both mindset and skill-wise).

  10. #10
    Banned
    Join Date
    Dec 2008
    Location
    Maputo, Mozambique
    Posts
    82
    If u get the handle of the cmd line console you can totally do xactly wut u sed. But as it was sed b4, its not trivial.

  11. #11
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Check out allegro or SDL.

    Allegro: http://alleg.sourceforge.net/

    SDL: http://www.libsdl.org/
    Woop?

  12. #12
    Registered User
    Join Date
    Dec 2008
    Posts
    36
    Install it on a Linux System and enjoy!

    Quote Originally Posted by Helgso View Post
    Ok, I found the program here: ftp://ftp.gtk.org/pub/gtk/2.14/

    But what can't figure out is how to install it. Help?

  13. #13
    Registered User
    Join Date
    Dec 2008
    Posts
    36
    Hi,


    I have asked a similar question- loading and displaying an image file. As soon as I know how to do that, I'll let you know.

    Don't be desperate!

    Quote Originally Posted by Helgso View Post
    I know already that you can change cmd's background and font color by doing:

    Code:
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    int main()
    {
            system("color 17");
            cout<<"This prints me gray on a blue background.";
            cin.get();
    }
    But is it possible to instead of changing cmd's background to a different color, can you instead make it display a background picture somehow?

  14. #14
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163
    What would be the picture format you are loading? Also be aware that you'll need to write your own function for decoding, formating to fit to the console and finally, displaying it by directly editing the console's buffer.
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM