Hi guys, I'm designing a form and trying to get different opacity values for different controls. How should i do it??
eg. clear visible text floating over 50% opaque form.

Here's a start.up w/2 Forms.

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.Opacity = 0.5
        Form2.Show(Me) '// keeps Form2 onTop of Form1.
    End Sub
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.Azure '// set bg.color to some color you'll never use.
        Me.TransparencyKey = Me.BackColor '// turn Form.Clear.
        Me.Location = New Point(Form1.Location.X + 5, Form1.Location.Y + 15) '// set location.
    End Sub

When moving Form1 around, have it where it keeps the location of Form2 by using Form1_Move event, If needed.
.hope this helps.:)

Here's a start.up w/2 Forms.

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.Opacity = 0.5
        Form2.Show(Me) '// keeps Form2 onTop of Form1.
    End Sub
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.Azure '// set bg.color to some color you'll never use.
        Me.TransparencyKey = Me.BackColor '// turn Form.Clear.
        Me.Location = New Point(Form1.Location.X + 5, Form1.Location.Y + 15) '// set location.
    End Sub

When moving Form1 around, have it where it keeps the location of Form2 by using Form1_Move event, If needed.
.hope this helps.:)

Well thanks for that new approach i was trying it with one form only but with a bit mod this too would work fine. The only problem is transparency key which anyways i wanted to avoid cause this procedure is not clean and if i use large font size or irregular designs or gradients in backcolor, it leaves traces of transparency key color, if only there was a better method...

This is what i finally managed
two forms and one class
form1

Public Class Form1
    Dim t As New title


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Opacity = 0.5
        Form2.Size = Me.Size
        Form2.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        Form2.Size = New Size(Me.Width - (2 * t.get_width(Me)), Me.Height - (t.get_height(Me) + t.get_width(Me)))
        Form2.Show()
    End Sub

    Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
        Form2.Location = New Point(Me.Location.X + t.get_width(Me), Me.Location.Y + t.get_height(Me)) '// set location.
    End Sub

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Form2.Size = New Size(Me.Width - (2 * t.get_width(Me)), Me.Height - (t.get_height(Me) + t.get_width(Me)))
    End Sub
End Class

form2

Public Class Form2
    Dim t As New title
    Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        SetStyle(ControlStyles.SupportsTransparentBackColor, True)

    End Sub


    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.Red '// set bg.color to some color you'll never use.
        Me.TransparencyKey = Me.BackColor '// turn Form.Clear.
        Me.Location = New Point(Form1.Location.X + Form1.Padding.Left + t.get_width(Form1), Form1.Location.Y + Form1.Padding.Top + t.get_height(Form1)) '// set location.
        Me.TopMost = True
        Me.ShowInTaskbar = False
    End Sub
End Class

everything is working perfectly fine, except when the first form losses focus the second form is still visible.How do i do that

Form2.Show(Me)'// add "Me" to your code and hope it helps. xD

And you should be able to remove Me.TopMost = True from Form2_Load.

.btw, I would create a Sub for Form2.Size and use that as needed. Makes it easier to manage.:)

Form2.Show(Me)'// add "Me" to your code and hope it helps. xD

And you should be able to remove Me.TopMost = True from Form2_Load.

.btw, I would create a Sub for Form2.Size and use that as needed. Makes it easier to manage.:)

Making it owner was good but can't do the same with size since the second form
is supposed to be border less if i directly pass values it will overlap first form's title bar and right side border.
Still is there anything that can make the text look smooth. I've also attached a screenshot
where the transparency key color used(gray) can be seen clearly.

>>Still is there anything that can make the text look smooth.
I've used .BackColor=Control and it returned unpleasant.
Changing the .BackColor to a very odd color, it worked fine here.
.other than this info, I am out of suggestions and glad that I could be of help so far.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.