By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Make a form "click through" or transparent to mouse events

P: n/a
I have been nagging for help on this subject for quite some time now.
Finally got it sorted out by my self.
Here is the code if some one else ever need it.

'Declarations:

Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hwnd As System.IntPtr, ByVal nIndex As Integer) As
Integer

Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As System.IntPtr, ByVal nIndex As Integer, _
ByVal dwNewLong As Integer) As Integer
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TRANSPARENT = &H20&

'In your sub:

Private Sub Form1_load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load

Call SetWindowLong(Me.Handle, GWL_EXSTYLE, _
GetWindowLong(Me.Handle, GWL_EXSTYLE) _
Or WS_EX_TRANSPARENT)
End sub

I find it quite useful to show help or info in a semi transparent form
TopMost = True, that ignores the mouse and keyboard actions so you can
go on working in the underlying windows but still be able to read the
help.
You have to controle the thread from your main form, so you can make a
button to close it with.

/Per Larsson
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.