Form With Shadow
-
Why don't you override CreateParams instead of creating FakeWindow? This example overrides default border and replace it with AERO. to get WS_ numbers, go to your Windows SDK and look under window.h for decleration
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
unchecked
{
cp.Style |= (int)0x80000000; // WS_POPUP
cp.Style |= 0x40000; // WS_THICKFRAME
}
return cp;
}
} -
when i said WS_ i meant WS_EX_NOACTIVATE and other. The one I post was uses AERO. It isn't limited for aero. It has all same as unmanaged code
-
when i said WS_ i meant WS_EX_NOACTIVATE and other. The one I post was uses AERO. It isn't limited for aero. It has all same as unmanaged code
-
When you say override CreateParams, did you refer to the main form's CreateParams? But then, where do I draw the png image files into?. Sorry, but I'm new in this so I'm still confused.
for painting try look into OnPaint event or you can even ovverride
roshihans wrote:
When you say override CreateParams, did you refer to the main form's CreateParams?
That is correct
-
for painting try look into OnPaint event or you can even ovverride
roshihans wrote:
When you say override CreateParams, did you refer to the main form's CreateParams?
That is correct
Saksida Bojan wrote:
for painting try look into OnPaint event or you can even ovverride
I thought if I paint form's border with a transparent-shadow background (using png file), it will not become transparent unless I set the main form transparent too. And how to paint the shadow into the border which is located in non-client area?
-
Saksida Bojan wrote:
for painting try look into OnPaint event or you can even ovverride
I thought if I paint form's border with a transparent-shadow background (using png file), it will not become transparent unless I set the main form transparent too. And how to paint the shadow into the border which is located in non-client area?
roshihans wrote:
And how to paint the shadow into the border which is located in non-client area?
Special 'Graphics' Objects to Draw Anywhere on your Window[^]
roshihans wrote:
it will not become transparent unless I set the main form transparent too
To enable Form transparecy you need to enable transparent color.
this.SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.DoubleBuffer, true);
-
roshihans wrote:
And how to paint the shadow into the border which is located in non-client area?
Special 'Graphics' Objects to Draw Anywhere on your Window[^]
roshihans wrote:
it will not become transparent unless I set the main form transparent too
To enable Form transparecy you need to enable transparent color.
this.SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.DoubleBuffer, true);
-
roshihans wrote:
And how to paint the shadow into the border which is located in non-client area?
Special 'Graphics' Objects to Draw Anywhere on your Window[^]
roshihans wrote:
it will not become transparent unless I set the main form transparent too
To enable Form transparecy you need to enable transparent color.
this.SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.DoubleBuffer, true);
-
Saksida Bojan wrote:
this.SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.DoubleBuffer, true);
It seems that SetStyle only applied in client area. I can't make the non-client area transparent. Any suggestion?
In a book i am reading, this is formula for getting transparecy displayColor = sourceColor × alpha / 255 + backgroundColor × (255 - alpha) / 255 ImageTraverser[^] This link is very good. Create a snapshot and you can get pixel. Image.GetPixel is super slow, this example is very fast.
-
I have a form and a png image file (with a transparent shadow in its border) and what I want is to make a drop shadow effect on the form. I know there are CS_DROPSHADOW solution for this, but I think it doesn't look too good. So I create a "fake" form using CreateWindowEx (via DllImport), and draw the png image file into the fake form.
void CreateFakeForm()
{
WNDCLASSEX wndClsEx = new WNDCLASSEX();
wndClsEx.Init();
wndClsEx.style = CS_VREDRAW | CS_HREDRAW;
wndClsEx.lpfnWndProc = m_DefWndProcDelegate;
wndClsEx.cbClsExtra = 0;
wndClsEx.cbWndExtra = 0;
wndClsEx.hInstance = GetModuleHandle(null);
wndClsEx.hIcon = IntPtr.Zero;
wndClsEx.hIconSm = IntPtr.Zero;
wndClsEx.hCursor = IntPtr.Zero;
wndClsEx.hbrBackground = IntPtr.Zero;
wndClsEx.lpszClassName = m_WndClsName;
wndClsEx.lpszMenuName = null;bool success = RegisterClassEx(ref wndClsEx) != 0; UInt32 dwExStyle = WS\_EX\_LAYERED | WS\_EX\_TRANSPARENT | WS\_EX\_NOACTIVATE | WS\_EX\_LEFT; UInt32 dwStyle = WS\_VISIBLE | WS\_OVERLAPPED; FakeWndHandle = CreateWindowEx(dwExStyle , m\_WndClsName , null , dwStyle , X , Y , PngImg.Width , PngImg.Height , MainFormHandle , IntPtr.Zero , GetModuleHandle(null) , IntPtr.Zero );
}
The problem is my fake form always in the topmost position. Is there a way to put the fake form behind the main form? In other words, how do I set z-order between the main form and the fake form so that the fake form placed at the bottom of the Z order? How to hide the fake form whenever the main form minimized or maximized, and move or resize the fake form whenever the main form moved or resized? Thanks.
how can i use the function 'CreateFakeForm'? could you give me the full project? I 1 2 create a nice shadow behind a customized form... Thanks