Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2006

Tip: Looking for answers? Try searching our database.

Click passthrough on forms/controls - help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Timothy - 27 Jan 2006 02:24 GMT
Hi everyone,
I hope someone can tell me an answer to this.

I want to make a form that is transparent, however, when you click it, the
event does NOT fire. Instead I want the applicatoins/desktop to be clicked
instead.

So its basically like a dead form.

I have seen this funcitonality on a Winamp plugin called Toaster. Anybody
know how to do it?

Thanks heaps in advance,

Tim.
Gabriele G. Ponti - 27 Jan 2006 18:30 GMT
I don't believe it's supported by the .NET Framework, but if you don't mind
doing PInvoke you can use the Windows regions APIs.

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace RegionsDemo
{
   public partial class RegionsDemoForm : Form
   {
       [DllImport( "gdi32.dll" )]
       static extern IntPtr CreateRectRgn( int nLeftRect, int nTopRect, int
nRightRect, int nBottomRect );

       public enum CombineRgnStyles : int
       {
           RGN_AND = 1,
           RGN_OR = 2,
           RGN_XOR = 3,
           RGN_DIFF = 4,
           RGN_COPY = 5,
           RGN_MIN = RGN_AND,
           RGN_MAX = RGN_COPY
       }

       [DllImport( "gdi32.dll" )]
       static extern int CombineRgn( IntPtr hrgnDest, IntPtr hrgnSrc1,
IntPtr hrgnSrc2, CombineRgnStyles fnCombineMode );

       [DllImport( "user32.dll" )]
       static extern int SetWindowRgn( IntPtr hWnd, IntPtr hRgn, bool
bRedraw );

       [DllImport( "gdi32.dll" )]
       static extern bool DeleteObject( IntPtr hObject );

       public RegionsDemoForm()
       {
           InitializeComponent();
           AddTransparentRegion();
       }

       private void AddTransparentRegion()
       {
           IntPtr windowRgn = CreateRectRgn( 0, 0, this.Width,
this.Height );
           IntPtr areaRgn = CreateRectRgn( 50, 50, 200, 200 );
           IntPtr combinedRgn = CreateRectRgn( 0, 0, 0, 0 );

           CombineRgn( combinedRgn, windowRgn, areaRgn,
CombineRgnStyles.RGN_XOR );

           SetWindowRgn( this.Handle, combinedRgn, true );

           DeleteObject( combinedRgn );
           DeleteObject( areaRgn );
           DeleteObject( combinedRgn );
       }

       private void Form1_Resize( object sender, EventArgs e )
       {
           AddTransparentRegion();
       }

   }
}
Timothy - 28 Jan 2006 01:44 GMT
Hi, thanks for your reply.

However, its just not what I'm looking for. I want to be able to click on a
label, and not have it be clicked.

Your code is close to what I'm looking for, however, the parts you can click
through are completely transparent. I only want it a little transparent.

Any ideas of how to do it?

>I don't believe it's supported by the .NET Framework, but if you don't mind
>doing PInvoke you can use the Windows regions APIs.
[quoted text clipped - 63 lines]
>    }
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.