Click here to Skip to main content
16,005,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual C++ .NET 2003 Suppress method Pin
Christian Graus17-May-05 14:31
protectorChristian Graus17-May-05 14:31 
GeneralChanging FOREground color of edit control Pin
peterchen17-May-05 8:17
peterchen17-May-05 8:17 
GeneralRe: Changing FOREground color of edit control Pin
PJ Arends17-May-05 8:38
professionalPJ Arends17-May-05 8:38 
GeneralRe: Changing FOREground color of edit control Pin
peterchen17-May-05 10:01
peterchen17-May-05 10:01 
GeneralRe: Changing FOREground color of edit control Pin
Ken Fredrikson17-May-05 11:21
Ken Fredrikson17-May-05 11:21 
GeneralI don't think so Pin
peterchen17-May-05 11:25
peterchen17-May-05 11:25 
GeneralRe: Changing FOREground color of edit control Pin
Ryan Binns17-May-05 18:49
Ryan Binns17-May-05 18:49 
GeneralRe: Changing FOREground color of edit control Pin
Jack Puppy17-May-05 19:14
Jack Puppy17-May-05 19:14 
I think it was a Paul Dilascia article that used this technique.

I used it in his folder tab class so that it would toggle the text color between black and white based on the color the user selects for the background color. (similar to what Excel does) I couldn't find the Dilascia article that used the code, but I still have the code kicking around in an old project:

<br />
int AfxGetLuminosity(COLORREF color)<br />
{<br />
	//------Last Checked------//<br />
	// - June 13, 2003<br />
<br />
	const int HLSMAX = 240;<br />
	const int RGBMAX = 255;<br />
	<br />
	int nRed = GetRValue(color);<br />
	int nGreen = GetGValue(color);<br />
	int nBlue = GetBValue(color);<br />
<br />
	int nRGBMax = max(max(nRed, nGreen), nBlue);<br />
	int nRGBMin = min(min(nRed, nGreen), nBlue);<br />
<br />
	return (((nRGBMax + nRGBMin) * HLSMAX) + RGBMAX) / (2 * RGBMAX);<br />
}<br />


In the folder tab drawing function I have:
<br />
COLORREF crText = ((AfxGetLuminosity(m_color) > 120) ? RGB(0,0,0) : RGB(255,255,255));<br />


where m_color is the background color. I seem to remember it not being 100% fullproof, and that asking in the newsgroups resulted in a "there is no sure fire method" answer.



Suspicious | :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
GeneralActiveX control: update when not selected Pin
peterchen17-May-05 7:30
peterchen17-May-05 7:30 
GeneralRe: ActiveX control: update when not selected [edit] Pin
PJ Arends17-May-05 7:48
professionalPJ Arends17-May-05 7:48 
GeneralRe: ActiveX control: update when not selected [edit] Pin
peterchen17-May-05 8:15
peterchen17-May-05 8:15 
GeneralRe: ActiveX control: update when not selected Pin
Ravi Bhavnani17-May-05 8:48
professionalRavi Bhavnani17-May-05 8:48 
GeneralRe: ActiveX control: update when not selected Pin
peterchen17-May-05 9:51
peterchen17-May-05 9:51 
GeneralRe: ActiveX control: update when not selected Pin
Ravi Bhavnani17-May-05 9:56
professionalRavi Bhavnani17-May-05 9:56 
GeneralRe: ActiveX control: update when not selected Pin
peterchen17-May-05 10:11
peterchen17-May-05 10:11 
GeneralRe: ActiveX control: update when not selected Pin
Ravi Bhavnani17-May-05 10:16
professionalRavi Bhavnani17-May-05 10:16 
GeneralRe: ActiveX control: update when not selected Pin
peterchen17-May-05 11:23
peterchen17-May-05 11:23 
QuestionHow to disable mouse wheel Pin
kalyanramu17-May-05 7:02
kalyanramu17-May-05 7:02 
AnswerRe: How to disable mouse wheel Pin
David Crow17-May-05 7:41
David Crow17-May-05 7:41 
AnswerRe: How to disable mouse wheel Pin
James R. Twine17-May-05 8:18
James R. Twine17-May-05 8:18 
GeneralRe: How to disable mouse wheel Pin
Anonymous17-May-05 12:37
Anonymous17-May-05 12:37 
AnswerRe: How to disable mouse wheel - Answer Pin
Tim Zorn11-Jun-05 15:42
Tim Zorn11-Jun-05 15:42 
QuestionDrive/Directory operations over a network ? Pin
Still learning how to code17-May-05 6:33
Still learning how to code17-May-05 6:33 
AnswerRe: Drive/Directory operations over a network ? Pin
Ravi Bhavnani17-May-05 6:44
professionalRavi Bhavnani17-May-05 6:44 
GeneralNeed HElp : File monitor Pin
inbakumar.G17-May-05 6:18
inbakumar.G17-May-05 6:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.