开发者

Make a Form's clicks "fall through" to the application below

I've made a form with an opacity of 30%, and I want this to开发者_Python百科 overlay on my screen so I can draw a grid on it whilst still being able to control any programs underneath. So I want the form I created with the grid to ignore my mouse events, so I can click through to the program underneath but still have it displaying on top.

Any ideas on this one?


You can specify Transparent Key Color to some color value of forms backcolor for clickthru area this color should be different from Grid Color you choose

This is VB.Net Code I tried should not be difficult to convert to C#

Private Sub frmTest_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    Dim rc As Rectangle = New Rectangle(0, 0, Me.Width - 1, Me.Height - 1)
    Using br As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.Cross, Color.Silver, Color.Transparent)
        e.Graphics.FillRectangle(br, rc)
    End Using
End Sub

Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.TopMost = True : Me.Opacity = 10% : Me.WindowState = FormWindowState.Maximized
    Me.BackColor = Color.White
    Me.TransparencyKey = Color.White
    Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜