 |

|
There is a problem when double click on alpha form. How can I solve it?
|
|
|
|

|
this is great! question: is there any way to make the overlay unclickable / not lose window focus of other programs if clicked?
|
|
|
|

|
Really a code i searched so far
|
|
|
|

|
Thank you so much for this great article, but can you give me the project files? *csproj
|
|
|
|

|
Do you know how can i add a onclick event to the forms?
5/5 stars
|
|
|
|
|
|

|
Great job, it looks great! I was just wondering, how would I go about drawing shapes such as rectangles, ellipses and lines using GDI? I've tried creating a Graphics object with the Graphics.FromHdc method but when I try drawing something, it doesn't appear.
|
|
|
|

|
Hi, I wanted to use this code inside an MDI Container to darken the area around an dialog box (like Vista/7 does), but I can't really figure out how to do it.
When I try to make the image bigger than it's 'physical' size is, it just isn't displayed. Do you know how to solve this prob? I haven't found a solution so far.
|
|
|
|

|
Is there a way to display a tooltip for a control on the form?
the controls are displayed with your code:
Bitmap temp_bmp = new Bitmap(bitmap);
foreach (Control ctrl in this.Controls)
{
ctrl.DrawToBitmap(temp_bmp, ctrl.Bounds);
}
|
|
|
|

|
Can you give use link of whole project with *.csproj or sln files,, b`coz it is difficult to create and load any form single file in VS 2005
|
|
|
|
|
|

|
Used your code in my project, works flawless
Thank you!
|
|
|
|

|
I made an image in the GIMP and saved it as a transparent png but it isn't working?
I'm getting the "The bitmap must be 32ppp with alpha-channel." exception. How do I check to this? I've never hear of "ppp" before.
-Elmernite
After editing around I found that I need to set "Save color values from transparent pixels" With that checked it works.
modified on Thursday, December 17, 2009 11:37 AM
|
|
|
|

|
I noticed that anchoring doesnt work if you use PPAB,
I think its because of the way controls are drawn to bitmap, anchor offsets are not taken into account, Can you help me fix this ?
|
|
|
|

|
Is it possible to draw on that image ? say a rectangle ?
What is the way to access the pixel buffer and modify it ? rgba-wise
Would it take a double buffer for the drawing to avoid the flickering ?
tx
|
|
|
|

|
Here is a workaround:
...
class PerPixelAlphaForm : Form
{
<code>Timer _RefreshFormTimer = new Timer();</code>
public AlphaForm()
{
// This form should not have a border or else Windows will clip it.
FormBorderStyle = FormBorderStyle.None;
<code>_RefreshFormTimer.Interval = 10;
_RefreshFormTimer.Tick += new EventHandler(RefreshFormTimer_Tick);
_RefreshFormTimer.Enabled = true;</code>
}
<code>private Bitmap _FormBitmap;
private byte _FormOpacity;
private void RefreshFormTimer_Tick(object sender, EventArgs e)
{
if (_FormBitmap != null)
SetBitmap(_FormBitmap, _FormOpacity);
}</code>
/// <para>Changes the current bitmap.</para>
public void SetBitmap(Bitmap bitmap)
{
SetBitmap(bitmap, 255);
}
...
...
public void SetBitmap(Bitmap bitmap, byte opacity)
{
if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
throw new ApplicationException("The bitmap must be 32ppp with alpha-channel.");
<code>_FormBitmap = bitmap;
_FormOpacity = opacity;</code>
// The ideia of this is very simple,
// 1. Create a compatible DC with screen;
// 2. Select the bitmap with 32bpp with alpha-channel in the compatible DC;
// 3. Call the UpdateLayeredWindow.
IntPtr screenDc = Win32.GetDC(IntPtr.Zero);
IntPtr memDc = Win32.CreateCompatibleDC(screenDc);
IntPtr hBitmap = IntPtr.Zero;
IntPtr oldBitmap = IntPtr.Zero;
try {
<code>
foreach (Control ctrl in this.Controls)
ctrl.DrawToBitmap(bitmap, ctrl.Bounds);
</code>
hBitmap = bitmap.GetHbitmap(Color.FromArgb(0)); // grab a GDI handle from this GDI+ bitmap
oldBitmap = Win32.SelectObject(memDc, hBitmap);
Win32.Size size = new Win32.Size(bitmap.Width, bitmap.Height);
Win32.Point pointSource = new Win32.Point(0, 0);
Win32.Point topPos = new Win32.Point(Left, Top);
Win32.BLENDFUNCTION blend = new Win32.BLENDFUNCTION();
...
Gottdrak99
modified on Thursday, November 27, 2008 3:22 AM
|
|
|
|
|

|
Hi,
I'm looking for a function simular as this code.
But I don't need a transparent form - I just need a transparent control inside a form.
Maybe somebody can help.
Thanks,
Andre
|
|
|
|

|
just great!
peace & serenity
|
|
|
|

|
why using old win32 with .net and c#...? get rid of those old gdi handles...
|
|
|
|

|
How would I get this working with VB.Net 2005?
|
|
|
|
|

|
Add some controls to overlay transparent form and avoid refreshing it's content with common Refresh()/Invalidate() methods,
use UpdateLayeredWindow() instead. For correct controls rendering add code like
Bitmap temp_bmp = new Bitmap(bitmap);
foreach (Control ctrl in this.Controls)
{
ctrl.DrawToBitmap(temp_bmp, ctrl.Bounds);
}
hBitmap = temp_bmp.GetHbitmap(Color.FromArgb(0)); // grab a GDI handle from this GDI+ bitmap
to the PerPixelAlphaForm::SetBitmap() method. Every System.Windows.Forms controlhas method DrawToBitmap().
Actually, i used this way to render simple controls - labels, i don't know would it work with more complex
user controls, but i can't see why it should not
|
|
|
|

|
I want mesure a length of a line by using pixel.Can u send me C# coding for that
fbgsd asgtdfg
|
|
|
|

|
I've compiled the source by using the bat file but I'm still not able to get the Images to show up. What am I missing?
|
|
|
|

|
(Sorry for the poor English)
Hi,
I got a strange problem.
In my form i add something like :
[DllImport("user32.dll")]
private static extern int SetParent(IntPtr hWndChild, int hwndNewParent);
[DllImport("user32.dll", EntryPoint="FindWindowA")]
private static extern int FindWindow(string lpClassName, string lpWindowName);
private int GetDesktopWnd() {
return FindWindow("Progman", null);
}
private void button1_click(object sender, System.EventArgs e) {
SetParent(pngForm_.Handle, GetDesktopWnd);
}
So when I click button1 my pngForm_ is now drawed on the desktop.
This worked great with 1 monitor.. But now I'm dual-monitoring and I got a bug when I try to move the pngForm_ when it's on the desktop. By example I hit the form when it's on monitor 1, and the form go on monitor 2 at the same position, and after it's impossible to move it.
I have made a lot of test, and i thinks it's due to the cp.ExStyle. In Fact when I remove the WS_EX_LAYERED it works..
Any idea to repair that ?
-- modified at 8:51 Saturday 7th October, 2006
|
|
|
|

|
Isn't it easier to use Forms.Opacity?
|
|
|
|

|
Hi,
This is some great code, I pissed around for ages trying to get this working before I stumbled across this page.
Now, it works just fine, the only thing is that forms descended from a PerPixelAlphaForm don't work in the VS2005 designer, you just get:
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.
Error creating window handle.
This doesn't stop the project from building or running though, but it's a pain not being able to use the designer.
Any ideas?
Thanks!
|
|
|
|

|
Someone said "make the main form's Owner the shadow form",but I don't kown how to do this,Please help me!
thanks a lot!
|
|
|
|

|
Hi dear
Can you recognition coordinate of circle in bitmap?
i searching a algorithm for do this task but i cann't find
I want search a sample picture in another picture .
for example I give a circle picture to program then program search this picture in another picture ,if find get me coordinate of circle picture.
Thank
|
|
|
|

|
I was wondering if there was a way to get the same functionality using direct X. I see how you can use alpha blending for 3d objects, but how would you do it for a 2d png image and the desktop?
#teve
|
|
|
|

|
Since you called it "Form" (PerPixelAlphaForm) shouldn't we be able to add controls to it like labels and stuff?
Right now its only use seems to be the display of pictures over the desktop with full alpha support which is good, but rather limiting.
Is there any other project which implements full alpha support as a form background?
Luís Ferrão
|
|
|
|

|
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'?
|
|
|
|

|
my mouse always through the window.
You demo window can not get the "hit test" message.
sorry, my English is very poor.
|
|
|
|

|
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!!
|
|
|
|

|
...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!
|
|
|
|

|
after the image is dragged around
the screen it becomes a simple form.
other then this, AMAZING stuff !
Michael
|
|
|
|

|
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
|
|
|
|

|
My question is simple can I build a control with per pixel alpha blending?
|
|
|
|

|
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.
|
|
|
|

|
If we write bellow codes -
#define WINVER 0x0500 // this is needed for UpdateLayeredWindow
#define _WIN32_WINNT 0x0500 // this is needed for the WS_EX_LAYERED
in StdAfx.h for using Alpha blending, then CFileDialog will not be available.
Do you know some good idea?
|
|
|
|

|
I think it would be cool to have a window that has a title bar that is opaque but a client area that is translucent but text on that client area would be opaque.
Any idea how to do this?
Thanx
|
|
|
|

|
Is there a way to make this work on Windows 98 and ME ?
|
|
|
|

|
I'll try to use that feature in my next version (in C#) of NovaClock! Thanx!
(Best Regards,)
Patrick Hoffmann
-------------------------------------------------------------------------------
Technical and Operations Manager, System Analyst, Software Architect
PGP: http://www.novacom.net/pgp/PatrickHoffmann.asc
-------------------------------------------------------------------------------
veturo, der kostenlose NOVACOM Routenplaner für Europa... http://www.veturo.de
--------------------------------------------------------------------------
|
|
|
|
 |