Thread: problem w/ color functions && win98 :P

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    49

    problem w/ color functions && win98 :P

    Hello.

    I have color functions that look like this:

    Code:
    void tred()
    {
    	#ifdef WIN32
    		HANDLE hstdo;
    		hstdo = GetStdHandle(STD_OUTPUT_HANDLE);
    		SetConsoleTextAttribute(hstdo, FOREGROUND_RED);
    	#endif   
    }
    And I have them print out colors on the console, like in a menu like this:

    Code:
    void main_menu()
    {
    	tdefault();system("cls");
    	
    	printf("\n\n\n\n\n\n\n\n\t\t\t  ");face_menu_titlebar();
    	printf(" MENU: Main Menu         ");tdefault();printf("\n\t\t\t  ");bdefault();
    	printf(" 1. New Campaign         ");tdefault();printf("\n\t\t\t  ");bdefault();
    	printf(" 2. Options              ");tdefault();printf("\n\t\t\t  ");bdefault();
    	printf(" 3. Exit                 ");tdefault();printf("\n\t\t\t  ");bdefault_i();
    	printf(" Type in # corresponding ");tdefault();printf("\n\t\t\t  ");bdefault_i();
    	printf(" to desired choice.      ");tdefault();printf("\n\t\t\t  ");tdefault();
    
    	char main_menu_select = _getche();
    
    	if(main_menu_select=='1') {difficulty_select();}
    	if(main_menu_select=='2') {menu_options();}
    	if(main_menu_select=='3') {exit();}
    	  else main_menu();
    }
    In windowsXp, it works perfectly fine. In win98, it SOMETIMES works perfectly fine. But heres the problem:

    Tn win98, it will 1/4 the time print the text with the proper colors correctly. As an error, it sometimes prints the background of a text to be black instead of grey sometimes. Even worse, it sometimes prints yellow longer than its supposed to, even though I CLEARLY stated it to print back to black again afterwards.

    What is wrong with win98 here. Its annoying, because during a combat phase in my game, I have to cls a status bar that changes color as you take damage, but sometimes it prints black instead of red. Its like it might be looking over it sometimes. But it onlysometimes doesnt print. I even turned off all optimizations in the compile, but it still does it. Even tryed fflush, but it does the same still.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Which compiler?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    49
    microsoft visual c++ 2005 express

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  3. Problem w/ console application compadibility
    By DarkMortar in forum C Programming
    Replies: 2
    Last Post: 05-16-2006, 07:13 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM