How can I make a transparent BUT clickable form

NoobCube

New member
Joined
Jan 9, 2013
Messages
4
Programming Experience
Beginner
Hello!
tried to search for something like this but all the info is how to create fully transparent form.

I am trying to make form that will be transparent but I want to be able to click in it.
I am creating form, set it BackColor to some color, then I set the TransparencyKey to match that color, I got transparent form but I can't click in it.
How can I make it clickable?

Thanks!
 
hmm
There should be some way to do it, maybe some .dll or something :moody:

-- EDIT --

Maybe its possible to add some control there such as button, text etc. that will fill the form and will allow user to click it instead? (also transparent bg)
 
Last edited:
Why not describe what you want to accomplish by drawing a picture or something? It's pretty hard for us to understand what you want to do if we do not know what the problem is, what the goal is.
 
My understanding is that this type of UI customization is far easier to do in WPF than WinForms, would it be possible for you to make a WPF app?
 
I never heard of WPF, I don't know what is it and how to use it :(

What I want to do is lets say I have 100x100px form which has 2px border for example, and button in center.
and that form bg is transparent, I want to be able to click the background and drag the form.
 
Ah so really it's completely different from your original question...

<DllImport("user32.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
 
<DllImport("user32.dll")> _
Private Shared Function ReleaseCapture() As Boolean
End Function
 
Private Const WM_NCLBUTTONDOWN = 161
Private Const HTCAPTION = 2
 
' Window is movable while not transparent by dragging from any of its control's client area.
Private Sub TransparentNotify_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    ReleaseCapture()
    SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End Sub


This works by intercepting mousedown messages directed at the client area of the form or control, and replacing it with a non-client-area (e.g. the title bar) mousedown event directed at the form. Note that you need to handle the MouseDown event of every control inside the form you want to be draggable (typically labels, groupboxes, etc... Any "passive" control...).
 
Last edited:
Back
Top