|
Ya I'll tell ya how to do it.
Create a form based on the perpixelalphablended deal and load it up with your background png.
Next create another dummy form. Make this form the exact same size as the perpixelalpha form. Add all the controls that you want on top of this dummy form.
Now, in the contstructor of your dummy form create a region that specifies all the areas where you controls are and set it to the form like shown below.
<br />
public Form1()<br />
{<br />
System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath();<br />
<br />
p.AddRectangle(new Rectangle(0,0, 803, 24));
p.AddRectangle(new Rectangle(53, 122, 60, 40));
<br />
this.Region = new Region(p);<br />
}<br />
OR the other way... NOT using Regions. Make your dummy form a nice color like 255,0,255 and then set the transparency key to 255,0,255 also. This will work better than regions actually, because when you move your form you wont see the ugly dialog background color behind the controls.
Then position your dummy form exactly over top of your perpixel form. Then write some funky code to move each form at the same time when dragged.
If someone has a better way to it (I doubt it), then I CHALLENGE you to post the code here.
To move the windows simultaneously was easier than I thought. Gotter going perfectly. Keep checking www.clubdjpro.com for the DJRipper. Then you will see what it is capable of.
Then yer all good.
Cheers,
Greg
-- modified at 12:50 Tuesday 24th October, 2006
|
|
|
|
|
i have been messing around with your code for a whole day now and i still cant do i want.
i am trying to get the output of your code to go into a panel background, that way i can have a transparent alpha blended background and still have labels and stuff on it that are set to transparent so that the background can be seen.
Ive tried but i am new to this area of .net
That and i am implementing your code into a vb.net project
Thanks
Goran
|
|
|
|
|
i complete the work but i have a problem when i minimize the main form the others form not minimize
if i make it minimize i can't make all of them maximize the main form only will be max. and the others with not appear
MAZRO3
|
|
|
|
|
Hi,
Is there anyone who can guide me to create slices of an image? Well, let me explain in more detials. I have an image and I want to cut that into three pieces (I dont want to loose quality).
Any idea will be highly appreciated.
Thanks,
|
|
|
|
|
When I F5'd the sample (I'm natively a VB programmer and that's what we do), sometimes the window would be arbitrarily clipped so that not all the image was visible. And this was a fairly random occurrence. Has anyone else noticed this behavior?
Also, with the XP theming on, an image that bleeds to the edge would show the curved edges of the top of the window. Probably not what you want.
I think that I have found a solution. If you use the Win32 api function SetParent to set the window's parent to the desktop, both of these unusual behaviors disappear.
Gary Christopher Mann
Computer Science Undergraduate
Georgia Institute of Technology
Atlanta GA, 30332
'The MIT of the South, or is MIT the Georgia Tech of
the North'?
|
|
|
|
|
I am having the same problem with some of my own png's as well as the 'veggie' sample. Tried setting the parent to the desktop to no aval.
TestForm = new MyPerPixelAlphaForm();
TestForm.Parent = null ;
Win32.SetParent(TestForm.Handle,(IntPtr) 0) ;
TestForm.Show();
Oh well, guess I'll come back to it after dinner.
Tom
|
|
|
|
|
I saw that problem too.
What worked for me was setting the following in my PerPixelAlphaForm subclass' constructor:
this.Width = m_background.Size.Width;
this.Height = m_background.Size.Height;
Where m_background is the Bitmap image.
-J
|
|
|
|
|
The problem was related to the FormBorderStyle not being FormBorderStyle.None.
This article should update soon, in the meantime get the source here.
----
Rui Lopes
|
|
|
|
|
my mouse always through the window.
You demo window can not get the "hit test" message.
sorry, my English is very poor.
|
|
|
|
|
You may want to make sure that the size of your form is the size of the bitmap.
this.width = bitmap.width ;
this.height = bitmap.height ;
There are definitely mouse issues (hitting the window underneath) if you don't do this.
Tom
|
|
|
|
|
Rui,
I used your code as the basis for a per pixel alpha demo in my tutorial at:
http://www.codeproject.com/cs/media/CsTranspTutorial3.asp
I was fascinated by your demo, but I didn't know enough to make any use of it, so I did a study that lead to my three transparency tutorials, and got to where I think I understand what you are doing just enough to be dangerous.
The per pixel alpha transparency demo comes up with a bottle of Aqua Mala water (guaranteed 90% pure) that can be dragged around the desktop and has a mouse sensitive 'button'. I really got a kick out of programming this little demo.
Thanks for getting me started in transparency.
Joe
|
|
|
|
|
Where might I find an example of this, but using vb.net? I know the code is very similar but I have had no luck porting the code. Please help! This is exactly what I need to use and I have not found another example like this!!
|
|
|
|
|
Andrew,
You shouldn't need to port the code. As Rui mentions in his article, all you need to do to use his code is derive your form from the PerPixelAlphaBlend class. In .NET, you can derive a VB form from a C# class, no problem. So you don't need to port this code at all.
~Steve
|
|
|
|
|
noob here!!! how would you do that??
|
|
|
|
|
...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
|
|
|
|