|
peterchen wrote:
And is there a simple algorithm to determine if two colors have enough "contrast" to be distinguishible?
Yes there is, but I can't remember it or find it right now. I know one exists though. I think it was something like calculating the luminance of the two colours (HSL colour model...) and making sure the the difference between the two was above some threshold, or something like that.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
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 />
<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.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
I have an MFC ActiveX Full Control.
When modifying the appearance through member functions, an Invalidate() on the control (or the respective child windows) updates the control only if it has the focus.
Without focus, I'm pretty much "grounded": simulating a resize helps, but that's not really efficient.
Any idea?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
How about using RedrawWindow()? Invalidate() only invalidates the window (hence the name), but it will not redraw the window until it recieves a WM_PAINT message. RedrawWindow() invalidates the window and forces a WM_PAINT message to be sent.
[edit]
If you use the RDW_UPDATENOW flag.
[/edit]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
this doesn't work either (I think, I just killed my test case )
Further, I don't want to force a cmplete redraw each time, as there might be an otside loop over all displayed items (flicker galore)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
peterchen wrote:
updates the control only if it has the focus
Perhaps there's a bug in the control's painting logic? (It should paint the control regardless of whether or not it has focus).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
It is painted completely by a child control (which contains more child windows)
Basically, I'm wrapping an MFC CWnd-based conrol in an ActiveX
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Fair enough, but perhaps the CWnd -derived object's painting logic is flawed (i.e. it paints only if it has focus)? This is just a guess.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Fair enough but ( ) this isn't the problem, calling Invalidate does not result in an WM_PAINT message when the control has no focus.
I *think* it has to do something wiht the activation state of the control, but I'm not fluent enough with the full control COM interfaces (which IMO is a mess), nor the MFC wrappers.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I think the answer may lie in calling COleControl::InvalidateControl() . See this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ah thanks! this looks more like it - will try tomorrow!
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Hi all,
I want to disable functionality of mouse wheel in my application. I don't want the front end's scrollbars to scroll if user uses the mouse wheel.
Does any one how to do that. I would sincerely appreciate your help.
Thanks,
Kalyan
|
|
|
|
|
I'm curious why you would want to do that. The user has come to expect certain actions when the mouse wheel is used. For those actions to be different or non-existent in your application would seem a bit counterintuitive.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
The easiest way I can think of that is to "eat" the WM_MOUSEWHEEL messages, but as another poster has already said, it is a bad idea to change a user's expectations of their UI-interactive hardware.
That is one of the reasons why applications with Broken GUI pi$$ off so many people; they change the way things are supposed to work, or they do not work the way they are supposed to.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks for your replies guys.
One of my customer wants to disable the scrolling effect from mouse wheel in his application. This is for specific application. Can you please help me on how to disable the scrollwheel functionality. I don't have very good idea on windows user32.dll and messages. What are WM_MOUSEWHEEL Messages and how can I eat them. Is there any tutorial or example code to do this. I would sincerely appreciate your help guys.
Thanks,
Kalyan
|
|
|
|
|
it is very easy to do actually
use microsofts MSDN library for more information but all you need is
if(PeekMessage(0,&msg,0,0,1))
{
if(msg.message==WM_MOUSEWHEEL)
{
//code -- automatically destroys the "mousewheel" input
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg); //process the message
}
}
---- Tim Zorn
----------------no problem
|
|
|
|
|
Haven't had any suggestions on my previous posting
"Need a pointer in the right direction How do I change working drives, make directories, etc across a network (i.e. on a remote machine) ?? Can't seem to find any info on MSDN (but maybe I'm not looking for the right thing !! )"
Surely there must be a network version of _chdrive, _mkdir, etc, or the equivalent ?
Doug
Doug
|
|
|
|
|
Try using "\?\\machine\sharename" as your arg to the Win32 API CreateDirectory() . See this[^] link. Hope this helps.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
I am developing one application, i want to list all system used files, it may be exe, dll, etc. I downloaded one code from syteminternals.comm, they wrote separate sys file (alfa file monitor also). I need the following details
1. Without sys file how do hook the file sytems.
2. how do write the vxd for file sytems, if any sample code is avilble in net pls mention the website.
Regards,
|
|
|
|
|
This is very complex work, and the best way to do this is via the drivers (sys and vxd).
|
|
|
|
|
I am using Visual Studio 6.0.
I would like to use ShellExecute{} to launch the
registered email client and include a specific file
as an attachment to that email.
I don't want to include the 'To' email address
in the ShellExecute() call.
From Nishant's excellent article i have a starting point:
ShellExecute(this->m_hWnd,"open",
"mailto:nishinapp@yahoo.com","","", SW_SHOW );
How do I NOT include the email address but DO include
a file for attachment?
Thanks a lot,
Robert
|
|
|
|
|
I do not think that you can, you may have to use MAPI (look up "Simple MAPI" in MSDN).
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks James.
I'm slugging through MSDN - one of my least favorite ways of finding info
|
|
|
|
|
Hi All,
I'm trying to provide a C function with a Class method as a function pointer,
roughly declared- void (__cdecl *) (void *) . the problem is, of course,
the __thiscall calling convention which is given to a class method by
default. This generates a conversion error by compiler.
Is there a way to somehow "convert" or type-cast the function calling?
I've tried to type-cast and reinterpret_cast it. Even tried declaring the
function as __cdecl from within the class but no luck.
Thanks very much for your help!
|
|
|
|
|
Not a recommended practice.
1. Pass a pointer to the class instance to your C function and then invoke the class member from there.
OR
2. Declare a static member function of the class, call it from the C function (You still need to pass pointer to class instance to static member function) and then invoke other member functions through the class pointer.
|
|
|
|