Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

How do I get my VB.NET console application to be able to use the full range of 32-bit RGB color space?

$
0
0

I'm writing a console application using VB, Visual Studio Express 2012 for Desktop (version 2012.3), and the .NET framework version 4.5.

The framework allows me to set console colors from the original 16 CGA colors only. See the code snippet below:

Sub SetMyFavoriteColors()

        Console.BackgroundColor = ConsoleColor.DarkBlue
        Console.ForegroundColor = ConsoleColor.Yellow

End Sub

I've looked into using a Win32 API call to try to get the full range of colors (RGB 32-bit) but the Win32 Console API doesn't offer a helpful solution either. Or if it does, I'm overlooking it. I've considered trying to get a Window handle (HWINDOW) from which I could obtain a Device Context handle (HDC) and then use the GDI API's SetPalette() function to accomplish this, by I'm hoping there's an easier solution. I hate to drop into C code and call the old GDI to do this --- if even that would accomplish my goal.

Once I start my console application, I can dynamically alter it's properties using the Windows UI's properties dialog and this lets me set individual Red, Green, and Blue components each in the range (0-255) which makes for some really cool colors.

So how do I get this capability at run time and modify the colors programmatically? I sure would like some help on this one, guys! I'm stumped... and frustrated... and have spent way too many hours trying to find an elegant solution. ;)

 



Viewing all articles
Browse latest Browse all 21115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>