|
|
Comments and Discussions
|
|
 |
|

|
The code and sample application do not seem to work on my computer. I even tried the precompiled demo with the same result. I am running windows xp SP3. It compiles and runs just fine, but DimmerDialog::ShowForm() and DimmerDialog.ShowMessageBox() do not seem to do anything.
|
|
|
|

|
Hi Nishant,
Great Piece o f code.Thanks for sharing. Is it possible ShowForm() method to return DialogResult?.it will be more useful for many dialogs in an application.
Thanks,
Mathi.
யாதும் ஊரே ; யாவரும் கேளிர் !
|
|
|
|
|
|

|
The link is not working
Have someone a working link?
Thanks
|
|
|
|

|
Hi,
I'm Not too familiar with the language used for this example, however I really do need something like this to help the non computer literate users of my application understand that they need to complete the foreground form prior to proceeding. Is there any way this can be used within VB6, I was thinking maybe calling a basic "FADE ONLY" application as a separate process (shell the programme perhaps) then adding my form over the top (I can then use API to kill the "FADE" application once the user has attended to the form)
I have searched the Web High and low for an example of how to convert the entire screen to Grey Scale and leave a single window as full colour within VB6 and so far found only one example (that I currently use) but this is very slow and uses lost Resources.
|
|
|
|

|
Do you believe it possible to persist the grayscale effect permanently? As a theme perhaps? Thanks.
|
|
|
|

|
Is there a possiblity that this effect can be use in vb6?
-vb6 roots
-C# novice
-Power is reponsibility...
|
|
|
|

|
Very cool effect
Paul
|
|
|
|

|
computerguru92382 wrote: Very cool effect
Thanks man
Regards,
Nish
|
|
|
|

|
This code doesn't work on Dual Monitors. The second screen turns completely black.
|
|
|
|

|
H0G4N wrote: This code doesn't work on Dual Monitors. The second screen turns completely black.
I am a miserable programmer who's never worked on more than a single monitor - neither at work nor at home!
How does the normal Shutdown dialog behave on a multiple monitor setup?
Regards,
Nish
|
|
|
|

|
Windows handles it fine, however most coders do not take Dual Moniters into consideration.
Most of the screensavers here at the codeproject only display on one screen with the normal desktop still showing on the other screen.
|
|
|
|

|
H0G4N wrote: Windows handles it fine
Since I can't see how it is (since I only have one monitor) could you explain what you mean by "fine"? Does it show a background color on the 2nd monitor? Or does it show the gray scale capture of the primary monitor there? Or the gray scale capture of the second monitor?
H0G4N wrote: however most coders do not take Dual Moniters into consideration.
Because they still work on a single monitor system (like me)
Regards,
Nish
|
|
|
|

|
Fine as in "as expected". Fades into a nice grayscale of the current capture.
|
|
|
|

|
H0G4N wrote: Fine as in "as expected". Fades into a nice grayscale of the current capture.
Thanks. I don't have a 2nd one as I mentioned, but I'll see if I can heuristically code for an unknown 2nd or 3rd monitor
Regards,
Nish
|
|
|
|

|
That would be good. Wasn't a criticism of your code. It's just something that people should be aware of.
|
|
|
|

|
H0G4N wrote: That would be good. Wasn't a criticism of your code. It's just something that people should be aware of.
Actually, I very much appreciate your feedback. Until today, I never even considered the multiple monitor aspect since I've never worked on more than a single monitor.
Regards,
Nish
|
|
|
|

|
When you create the bitmap, you get the size with GetSystemMetrics(SM_CXSCREEN) and GetSystemMetrics(SM_CYSCREEN). Those return the size of the primary monitor, not the entire virtual desktop. Use SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN instead.
Then in the BitBlt() call, you use (0,0) as the source top-left coordinate, but that may not be the coordinate of the top-left of the virtual desktop. You can get that coordinate by passing SM_XVIRTUALSCREEN and SM_YVIRTUALSCREEN to GetSystemMetrics().
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
|

|
toxcct wrote: very good article anyway !
Thanks Man
toxcct wrote: too bad it's MC++
any plan to port this to MFC dear Nish ?!
Nope - trying to focus on .NET now
Regards,
Nish
|
|
|
|

|
Just for the record: The windows dialog doesn't switch to the secured winlogon desktops.
|
|
|
|

|
Thomas Weidenmueller wrote: Just for the record: The windows dialog doesn't switch to the secured winlogon desktops.
If that's so, do you have any source of information to point me to?
Regards,
Nish
|
|
|
|

|
Just press Alt+tab while the dialog is displayed. It means you're on the same desktop as the other windows.
|
|
|
|
|

|
Rama Krishna Vavilala wrote: That's interesting I never knew that you can press ALT+TAB when the shutdown dialog box is shown. I never tried. How come it never occured to me?
Same here - never tried that out
Regards,
Nish
|
|
|
|

|
Thomas Weidenmueller wrote: Just press Alt+tab while the dialog is displayed. It means you're on the same desktop as the other windows.
Holy crap! That is correct! I never tried Alt-Tab before
I'll update the article and remove the incorrect text.
Thanks, Thomas.
Regards,
Nish
|
|
|
|

|
LOL! Why have I never tried that either?!?!
C
|
|
|
|

|
mr.stick wrote: LOL! Why have I never tried that either?!?!
Yeah, it's not something you'd automatically try, eh?
Regards,
Nish
|
|
|
|

|
Article text has been updated. Thanks again.
Regards,
Nish
|
|
|
|

|
And staring at it, I couldn't figure out why:
1) the switch statement is is reverse order
2) the fourth case, colorReductionStep==4, is tested for in an if statement, rather than putting it in as a case.
Maybe I'm missing something?
Also, instead of four discrete steps, you could make a nice linear fade by calculating the luminosity of the pixel (probably factoring RGB perceived intensity differences) and then determining the target gray scale for the same luminosity. I'm sure there's actually a standard equation to make a color image gray. In fact, doesn't Christian have a function that does that? Then you'd get the nice smooth transition that Windows has.
One more question--why would one use this affect to indicate a "very important message box or form that requires immediate user attention"? I always laughed the XP fade, as it fades to gray, but then when you click on "ShutDown", the colors return. Ridiculous. Gray is also not as visible as color. What's wrong with the hand or exclamation icon? Just my personal opinion on UI design and not intended to be a reflection on your article.
Marc
Pensieve
|
|
|
|

|
Marc Clifton wrote: 1) the switch statement is is reverse order
The code evolved a lot while I tried to get the fade right. Eventually once I got it right, I left it like that - while it's not common, a reverse order switch works okay I guess
Marc Clifton wrote: 2) the fourth case, colorReductionStep==4, is tested for in an if statement, rather than putting it in as a case.
Again, a result of code evolution. The original code required an if-check. I guess I should clean this up a little - not that it particularly affects things - just weird to look at I guess/
Marc Clifton wrote: Also, instead of four discrete steps, you could make a nice linear fade by calculating the luminosity of the pixel (probably factoring RGB perceived intensity differences) and then determining the target gray scale for the same luminosity. I'm sure there's actually a standard equation to make a color image gray. In fact, doesn't Christian have a function that does that? Then you'd get the nice smooth transition that Windows has.
Does he? I looked around for something like that and couldn't find one. If there's a better algorithm that gives a smoother fade, I'd definitely like to use that. It should be fast though - some of the earlier code I tried took 7-8 seconds to render. (I admit to using GetPixel for the first version).
Marc Clifton wrote: One more question--why would one use this affect to indicate a "very important message box or form that requires immediate user attention"? I always laughed the XP fade, as it fades to gray, but then when you click on "ShutDown", the colors return. Ridiculous. Gray is also not as visible as color. What's wrong with the hand or exclamation icon? Just my personal opinion on UI design and not intended to be a reflection on your article.
I personally do not favor this sort of behavior. But these days, apps try their best to look as similar to Windows or Office as possible. For instance, when the next Office is out, we are gonna have lots of apps using that ribbon control, just like how today, a lot of apps use the Off 2003 style menu system and gradient shading.
I've been doing some C#/.NET coding the last couple of weeks just to get back to being familiar with it - and this article and the last one are the results of that. Thanks for the feedback, Marc.
Regards,
Nish
|
|
|
|

|
Nishant,
I like your approach to just curtain the "real" desktop with its own screenshot and then alter this one instead.
Concerning your fading algorithm. The "right" way to convert color to its corresponding grey value is a weighted mean value based on the different sensitivity of the human vision in the red, green and blue channel. The human eye is especially sensitive to green colors (probably because nature used to be mostly green) and least sensitive to blue. So the weights of the single channels have accordingly been defined as follows (my numbers differ slightly from yours, but in the end I doubt it would make a significant difference):
grey = 0.2126*red + 0.7152*green + 0.0722*blue
what you want to do now is find a function which lets you approach this ratio step by step.
(You appear to be doing this in four discreet steps already, having found the values by trial and error if I got you correctly ).
Now for example, let a variable "a" run from 0.0 to 1.0 in steps that you define and calculate the resulting channels like the following:
red_i = (1.0-a*(1.0-0.2126))*red + 0.7152*a*green + 0.0722*a*blue
green_i = 0.2126*a*red + (1.0-a*(1.0-0.7152))*green + 0.0722*a*blue
blue_i = 0.2126*a*red + 0.7152*a*green + (1.0-a*(1.0-0.0722))*blue
I havent actually tested these equations, but if you simply put a=0 you get a direct mapping red_i==red, green_i==green and blue_i==blue. If you set a=1 you will arrive at the above formula. So it should work and you should be able to replace your switch statement with a loop and run it with a resolution of your preference.
Hope it helps and thanks again for the article!
|
|
|
|

|
Nishant Sivakumar wrote: f there's a better algorithm that gives a smoother fade, I'd definitely like to use that. It should be fast though - some of the earlier code I tried took 7-8 seconds to render. (I admit to using GetPixel for the first version).
Use the algorithm Willi Deutschmann posted for calculating gray, if it's too slow then build a look-up table.
----
Bots don't know when people die.
--Paul Watson, RIP
|
|
|
|

|
Uhm, am I missing something? If you're getting back to C#, why use any C++ code at all, mixed or straight up? You could do the same stuff using pure C#. For example you could look at ColorMatrix for creating B&W conversion. You won't need to do any looping at all using ColorMatrix. With one call, poof, your image has a B&W copy.
T.
|
|
|
|
|

|
Nishant Sivakumar wrote: I sure don't want it traced back to me.
LOL! Or, as happened to me, when I discovered that a client, who had hired me as a consultant, had taken my code, BSD Licensed, and removed the license agreement (in violation of the BSD licence) but left certain key "signatures" of my code in the code. Like a comment I had made regarding a contribution leppie made to the code. And the client? Xamlon.
Marc
Pensieve
|
|
|
|

|
Marc Clifton wrote: And the client? Xamlon.
Did you let them have it?
Regards,
Nish
|
|
|
|

|
Nishant Sivakumar wrote: Did you let them have it?
As in, "sock-it-to-them"? No. As in "let them have the code", yes, but never formally. I just let it slide and filed it under "nice people, eh?"
Marc
Pensieve
|
|
|
|

|
Marc Clifton wrote: As in, "sock-it-to-them"? No.
Yep, that's what I meant.
Marc Clifton wrote: As in "let them have the code", yes, but never formally. I just let it slide and filed it under "nice people, eh?"
Okay, makes sense, considering they were contracting you at that time.
Regards,
Nish
|
|
|
|

|
Nishant Sivakumar wrote: Okay, makes sense, considering they were contracting you at that time.
Well, it was a timing thing--they had clearly incorporated the code before I was contracted.
Marc
Pensieve
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
DimmerDialog is a .NET class that shows a modal dialog which grays out the rest of the background, just like the Windows XP Shutdown dialog. This can be used when your application needs to show a very important message box or form that requires immediate user attention.
| Type | Article |
| Licence | CDDL |
| First Posted | 23 Feb 2006 |
| Views | 116,466 |
| Bookmarked | 78 times |
|
|