|
...since the System.Drawing already comes along with built in functions, which are not well commented but available to everyone, and work by means of HW accelerated blitting, thus decently fast.
But great article though; just wanna let u know!
|
|
|
|
|
Humm, System.Drawing alone? You have to show me how you do it!
----
Rui Lopes
|
|
|
|
|
bloodyduke wrote:
But great article though; just wanna let u know!
What article, this is purely a code sample.
Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat!
|
|
|
|
|
after the image is dragged around
the screen it becomes a simple form.
other then this, AMAZING stuff !
Michael
|
|
|
|
|
Humm, what do you mean with "..it becomes a simple form."? You don't want to be able to drag the image arround?
----
Rui Lopes
|
|
|
|
|
I have the same problem on XP. May be its an OS bug. Iworked around it with using the same UpdateLayeredWindow after processing the WM_SYSCOMMAND in the CDummyDialog, but it still flickers
Best regards,
X3m
|
|
|
|
|
I'm seeing the same problem on XP SP1.
My form is programmatically moved from off the bottom of the screen up toward the top. Sometimes the standard Windows Form UI elements appear again (title bar, minimize, close, etc) and my original translucent image is replaced by the default control color (grey) until SetBitmap() is called again.
I can't reliably reproduce this, but I'll post back if/when I figure it out how to. In the mean time, can the author (or anyone reading this) think of any reasons for this?
|
|
|
|
|
Think I may have answered my own question.
I was using invoke to call a function to move the window. This function was taking a long time to complete. I can only assume that while this was happening, my form wasn't processing windows messages, so Windows decided my form was unresponsive. Because of this, Windows changed it's appearance, like it does for other non-responsive apps.
My solution was to ensure that functions I invoke terminate quickly.
I hope this helps others with similar problems.
|
|
|
|
|
How to create a popup window with a shadow without using PNG files? For example a rectangular window with a shadow from the right and the bottom?
Thank you! U did a great job by the way
Best regards,
X3m
|
|
|
|
|
Dear sir£¬do you catch it£¿
i'm wonderring how to render a png picture with shadow,just like winamp3;
|
|
|
|
|
you can change your window class to have the CS_DROPSHADOW style (only works on WinXP+), take a look at,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/aboutwindow.asp#class_styles
or you can "fake" the shadow by creating two (or one) windows near the bottom and right edge of your window, then you need to write some code to move/hide that "shadow" windows when your main window is moved/hidden.
oh, and you do not need a png file, you can generate the shadow bitmap using the FillRectangle method and a LinearGradientBrush.
good luck,
-- Rui Lopes
|
|
|
|
|
Thank you!
Best regards,
X3m
|
|
|
|
|
My question is simple can I build a control with per pixel alpha blending?
|
|
|
|
|
I have the same question. I've been trying to build an ActiveX control (MFC) with no luck...
I've tried setting the WS_EX_LAYERED style for the control's window and using UpdateLayeredWindow (which returns the same error it returns if you haven't set WS_EX_LAYERED) and I've tried building a windowsless control and using alphablends in OnDraw(), neither have worked. Does anyone know how to do this or have ideas on what else to try?
Eric Hansen
ehansen@pmsi.cc
|
|
|
|
|
Using this component, I am unable to add controls. The controls are there, but not visible. If I change the form's opacity (the standard way, not with SetBitmap) I can see that the controls are in fact there, behind the image. Please enlighten me if possible as to how to add controls on top of the layered window.
|
|
|
|
|
Well, the short answer is, "you can't"....
Layered windows only display a RGBA bitmap. They don't receive paint messages; they allways show the RGBA bitmap that you have set. If you want to add some controls you have to rool your own solution. For example, when the state of the button changes you can paint it to the form bitmap and refresh it (SetBitmap). Or you can create a overlapping window, with the controls, and place that window on top of the layered window. Or <<other solution here>>!
----
Rui Lopes
|
|
|
|
|
When a form is made transparent using the Opacity property, controls on the form still work like normal. They receive clicks, they draw themselves, etc. How does the framework support this?
|
|
|
|
|
Well, re-read my reply. Windows does not support this so my code does not support it either; if you want to add regular controls you have to roll you own solution.
----
Rui Lopes
|
|
|
|
|
Rui, what does this mean? "Or <<other solution="" here="">>!"
Overall this is an interesting technique but it has many limitations. Not being able to directly draw on the form is obviously a pain. The technique I am going to use is to have the source image, draw it to an "active" image, make modifications as required (button state, focus rectangles, etc.) and use that with SetBitmap. Hopefully this will be flicker-free assuming I am not updating the UI every 10 ms. I have no idea how this is going to perform, but in a few hours I'll let you know.
What I have done is take your basic technique and created a 'generic' Skinnable form that allows the user to define control regions, state images for those control regions, proper mouse handling (non-trivial), enabling/disabling, visibility, IsTabControl, TabIndex, Key processing, etc... My goal is to be able to drive all this from an XML definition for the Skinnable form.
I think most people would want to place actual controls (such as Button) directly on top of the skin, but to me this is limiting. Instead I am going for the light-weight controls (non-.NET) and doing all the processing myself. What I need is a good technique for drawing on the skin. Drawing on the bitmap directly seems like the best technique for me assuming decent flicker-free performance. For others, the layered window approach might be best.
Tom
|
|
|
|
|
Please let me know how this works for you. I guess -- after reading the comments -- that's what i am going to have to do and you could save me a lot of time if it doesn't work ... Thanks for the help!
|
|
|
|
|
I forgot to post the results of my tests. It works great, and performance seems very acceptable. I tend to work on higher end machines so your mileage may vary. I tested on XP Pro and Win2K. No problems at all.
I am in the process of setting up a general purpose "skin" form that handles all the regions, mouse/keyboard processing, events, etc. for psuedo-controls on the skin. I.e, you have a skin, define regions, create "controls" for those regions and all the drawing (states), mouse/keyboard, focus, etc. is handled by the "skin" form and forwarded as appropriate to the controls. In essence it is like a Win Form with standard controls, but skinned and without using actual Win Form controls. I am not sure it is the best technique. Someone else may provide a mechanism to use the layered window technique with a windows form overlayed with normal buttons, sliders, etc. I simply find the technique interesting and flexible.
It is up and running and is working fabulously, but I am using it for a special project that does not currently do everything you would want the general purpose "skin" form to do. Ergo, I need a different example that really pushes it. Maybe a "skin" form around the Windows Media Player control would be a interesting sample.
Tom
|
|
|
|
|
One solution is to send a WM_PRINT message to the base window along with the PRF_CHILDREN|PRF_CLIENT flags on a timer. You'll have to specify the memory HDC of the bitmap. This does not, however, help with edit controls, since the cursor will not draw properly. You'll have to add yet another hack to this hack. Not sure how to do this in C# though.
|
|
|
|
|
I am having the same problem. Please help!!
|
|
|
|
|
Has anyone found a solution to this yet?
|
|
|
|
|
Is anyone found a solution how to add controls?
|
|
|
|