Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Monolith

How do I get the color attributes... ? (win console thing)

This topic is 6109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to get the color value from one position on the console screen (x,y). This is the best I can think of, but it doesn't seem to work:
    
unsigned char console::getcolor(unsigned char x,unsigned char y) {
     COORD coordinate={x,y};
	 unsigned short attributes[1]={0};
	 LPDWORD charsRead=0;

	 if (!ReadConsoleOutputAttribute(outH,&attributes[0],1,coordinate,charsRead))
	    return current_fgc+0x10*current_bgc;
	 current_fgc=attributes[0]%0x10;
	 current_bgc=attributes[0]/0x10;
	 return (unsigned char)(attributes[0]);
}
    
The ReadConsoleOutputAttribute function seems to always fail. (outH is a handle to the standard console output) Edited by - Monolith on October 29, 2001 6:17:14 PM

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!