Painting a Drop Shadow under a Form

P

Phil Jones

I would like to paint a drop shadow behind my forms - like the drop-shadow
that appears behind the mouse, and the StartMenu on XP.

I'm wondering is there some way to go about doing this. I have no problem
creating the complex alpha channel image for this - I just don't know how
and on what to render the drop shadow. Is there some master layter/Graphics
object I can get at to paint over all other forms.

[I've looked at non-rectangular shaped forms, but that doesn't work because
the transparency key is 1-bit - no smooth gradations possible there]

Many thanks!
===
Phil
(Auckland | Aotearoa)
 
J

Jeffrey Tan[MSFT]

Hi Phil

I will spend some time on this issue, I will reply to you ASAP. Thanks for
your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Phil,

Sorry for letting you wait for so long.

Actually, the drop shadow effect for a form can be turned on through adding
CS_DROPSHADOW to the window style. So we should override form's
CreateParams property and add the CS_DROPSHADOW, doing like this:
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ClassStyle |= 0x00020000;
return cp;
}
}

Note: the drop shadow effect is not always opened for a system, only when
drop shadow effect is turned on on a system, the CS_DROPSHADOW will take
effect. We can invoke SystemParametersInfo win32 API with SPI_SETDROPSHADOW
parameter to turn on the entire system's drop shadow effect, for more
information, please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas
e/systemparametersinfo.asp
=============================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
P

Phil Jones

Jeffrey! You little beauty. I wasn't expecting anything that easy. I'll
start making this happen right now.
 
J

Jeffrey Tan[MSFT]

Hi Phil,

Thanks for your sweet feedback :). I am glad I can help you, if you need
further help, please feel free to post, I will work with you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
P

Phil Jones

Hey Jeffrey - this might be a dumb question but I'm not sure how to write
that parm (0x00020000) value in VB.NET

Is there some hex processing I need to do with it - or what??

Many thanks

===
Phil Cockfield
(Auckland | Aotearoa)
 
J

Jeffrey Tan[MSFT]

Hi Phil,

Nothing, it can be writen as &H00020000.

Also, the value of many WIN32 const parameter can be found in the below .h
files:
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinUser.h
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\Windows.h
Such as CS_DROPSHADOW is defined in WinUser.h like below:
#define CS_DROPSHADOW 0x00020000

You may leverage VS.net IDE's Edit->Find and Replace->"Find in Files" to
search C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include directory for any system const value.

Hope this information makes sense for you!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Joe Blow

Is it possible to create / draw a bigger drop shadow on a windows form?
Your example was very nice and simple, but the drop shadow is very
small. I would like a bigger drop shadow (simular to the old text days
when all we had were text windows)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top