Link to home
Start Free TrialLog in
Avatar of dtleahy
dtleahyFlag for United States of America

asked on

VB6 - How to "dim" a screen?

VB6

There is a process of "dimming" the overall screen, using a boolean AND, or a boolean OR to blend the currently displayed overall monitor screen with a grid of gray dots. This technique is used by some versions of Windows when you click Start>Shutdown. Does anyone have some sample code to do this?

Thanks,

Dennis
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dtleahy

ASKER

Thanks for the replies, ryancys.

This may be what I need, but interestingly, it is the opposite implementation of what I want to do. They are using it to create a semi-transparent window on top, and I want to semi-obscure the screen below. I have some screens that are visually busy, and when I pop a smaller dialog in front of that, I'd like the busy background to drop further "into the background", to help focus the user.

I'll keep reading through those pages you linked to, but in the meantime maybe someone will have a simple boolean ANDED implementation of the window that I can check out.

Dennis
Avatar of dtleahy

ASKER

...which leads me to the term "Alpha Compositing", and a VB specific implementation:

http://www.vbaccelerator.com/home/vb/code/vbmedia/Image_Processing/Compositing/article.asp

still looking...

Dennis
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. The class allows you to show either a message box (where you can set the text, title and icon), or a Form instance.

download source here: http://www.codeproject.com/dotnet/DimmerForm.asp
Avatar of dtleahy

ASKER

Hi viralypatel, and thanks for the reply

This is indeed the effect I'm looking for, but is is .NET, and I need the same effect for a classic VB (VB6) application. I'm hoping I can find some VB code, rather than sample code in C++, or C#, or VB.NET.

Dennis
Avatar of dtleahy

ASKER

ryancys provided the correct answer in his first post. In fact, I may go back to the MSDN article and check out how to apply the partial transparency gradually (a true "fade-in" effect), using a timer. I was thinking too much "inside the box" and just because the article deals with making the top window in a layer transparent (not what I want), I didn't see that the code was right there in front of me. You can apply that functionality to any window, not just the top one!

As is pretty typical for the technical writers at Microsoft, the article gives more information than I wanted to swallow. They write with broad strokes.

So, when I kept looking, I found a more focused article: http://www.codeguru.com/vb/gen/vb_graphics/transparency/article.php/c6979/

...and, in following that code (which helped me accomplish my goal), I realized that the SetLayeredWindowAttributes was the key, and that ryancys had already led me to the info I needed.

For anyone else that finds this thread, looking for specifics on how to "dim" or "fade" the background, think about a strategy where you have 2 forms loaded, and that the first form loaded is a maximized borderless dialog, and has transparency applied to it, in its Form_Load event. The form popped above that could also have a degree of transparency, but if left opaque it does exactly what I wanted: focus the user on the topmost dialog.

The maximized form used for transparency could be a single color (like gray), but I used a graphics application to create an image with random monochrome noise added to it, and made that image the picture property of the form. Added a nice texture effect to the faded background.

Thanks again, ryancys!

Dennis