Solved

Get the RGB values from the custom color in visual studio

Posted on 2009-07-03
1
652 Views
Last Modified: 2012-05-07
Hi Experts,

I am running microsoft visual studio. I have a gui that prompts the user to select a custom color from the color dialog box.

Below is the code I have currently to get the hue, saturation, and luminosity.

Unfortunately, I cannot find a way to directly get the RGB values, which I would like to use instead of those values.
Can you please replace the snippet of code below with the code that would get teh RGB values.

THanks,

Dennis
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
 
				 this->colorDialog1->ShowDialog();
 
				 // Write the hue to the screen which is measured in degrees, ranging from 0.0 through 360.0, in HSB color space.
 
				 this->textBox1->Text = safe_cast<IConvertible ^>(colorDialog1->Color.GetHue())->ToString(nullptr);
 
				 // Write the brightness to the screen which ranges from 0.0 through 1.0, where 0.0 represents black and 1.0 represents white.
 
				 this->textBox6->Text = safe_cast<IConvertible ^>(colorDialog1->Color.GetBrightness())->ToString(nullptr);
 
				 // Write the saturation to the screen which ranges from 0.0 through 1.0, where 0.0 is grayscale and 1.0 is the most saturated.
 
				 this->textBox2->Text = safe_cast<IConvertible ^>(colorDialog1->Color.GetSaturation())->ToString(nullptr);
 
			 }

Open in new window

0
Comment
Question by:datopdogg7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 24770686
how about
colorDialog1->Color.R  for the red component, (G and B fror green and blue)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question