Question Filter Form Graphic

stulish

Well-known member
Joined
Jun 6, 2013
Messages
61
Programming Experience
3-5
Hi i am creating a program to be used on a ships bridge, the problem i have is at night they have to be able to swith to night mode, i have the program dimming the display but wanted to add a red filter to the form also, i have used Photoshop to show what i want to kind of do:

The Normal Form:
normal.png


Then with the RED filter applied:
filter.png

The form would have to react as normal to click events etc.

Does anyone have any ideas on how to do this, in android it is easy by using a panel and allowing click through events and setting it to 50% transparent.

Thanks

Stu
 
Hi guys,

just to let you know, i found something that works great : Transparent, Click-Through Forms - CodeProject
That's a useful CodeProject entry, but you could achieve the same result with much less code just by using form Opacity. Here's a code example which works perfectly and also deals with eventualities such as dragging, resizing or minimizing the form. For demo purposes, add a TrackBar (TrackBar1) to the form; its properties are set below in the code. You fade to red by scrolling the TrackBar.

VB.NET:
Public Class Form1

    Private BackForm As Form

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        BackForm = New Form
        Me.Owner = BackForm
        With BackForm
            .StartPosition = FormStartPosition.Manual
            .BackColor = Color.Red
            .FormBorderStyle = Windows.Forms.FormBorderStyle.None
            .ShowInTaskbar = False
            .Show()
        End With
        With TrackBar1
            .Minimum = 30
            .Maximum = 100
            .Value = 100
        End With
    End Sub

    Private Sub Form1_Move(sender As Object, e As System.EventArgs) Handles Me.Shown, Me.Move, Me.SizeChanged
        Dim r As Rectangle = Me.Bounds
        r.Inflate(-5, -5)
        If BackForm IsNot Nothing Then BackForm.Bounds = r
    End Sub

    Private Sub TrackBar1_Scroll(sender As Object, e As System.EventArgs) Handles TrackBar1.Scroll
        Me.Opacity = TrackBar1.Value / 100
    End Sub

End Class
The only thing that some people may be unfamiliar with is the Owner property of the form. It ensures that the owned form always stays in front of the owner, including when another window is shown or when the form is minimized. You will find that useful too if you decide to use a Layered Window.

BB
 

Latest posts

Back
Top