Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does TransparentKey actually work?

Status
Not open for further replies.

j0em0mma

Programmer
Jul 31, 2003
131
US
It seems so simple: Set BackColor =, say, red.
Set TransparentKey = red.
make sure RightToLeft is false

The form background should now be transparent. Am I missing something?
 
please note: there is a typo in my question. The code I am trying to run is:

Code:
    Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.BackColor = Color.Red
        Me.TransparencyKey = Color.Red

    End Sub
 
I've just tested that and it works perfectly. Are you sure that you are not also doing something else in your program that cancels the effect.


Hope this helps.

[vampire][bat]
 
I can get it to work on a simple form. however, when I try the solution that you and Christiaan gave me for including multiple forms on a parent form via panel, It does not work.

The main container looks like this behind:

Code:
Public Class frmMain

    Private WithEvents objFrmLogin As frmLogin
    Private WithEvents objFrmMenu As frmMenu
    Private WithEvents objFrmCustomers As frmCustomers


    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        objFrmMenu = New frmMenu
        objFrmMenu.TopLevel = False
        objFrmMenu.Dock = DockStyle.Fill
        pnlMain.Controls.Add(objFrmMenu)

        objFrmLogin = New frmLogin
        objFrmLogin.TopLevel = False
        objFrmLogin.Dock = DockStyle.Fill
        pnlMain.Controls.Add(objFrmLogin)

        objFrmCustomers = New frmCustomers
        objFrmCustomers.TopLevel = False
        objFrmCustomers.Dock = DockStyle.Fill
        pnlMain.Controls.Add(objFrmCustomers)

        objFrmLogin.Show()
    End Sub

End Class

And I want the transparencyKey applied to one of the subforms being loaded in the panel. The sub form looks like this:

Code:
Imports System.Drawing
Public Class frmLogin

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Parent.Controls.Item("frmLogin").Hide()
        Parent.Controls.Item("frmMenu").Show()
    End Sub

    Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.BackColor = Color.Red
        Me.TransparencyKey = Color.Red

    End Sub
End Class
 
My solution didn't use a panel, I just added the child forms to the parent form's controls collection.


Hope this helps.

[vampire][bat]
 
Sorry it took some time for me to get to a place where I could re-engineer this.

Welp, I removed the panel and added the child forms to the control collection of the main form. Unfortunately, same problem... I cannot make the childform transparent. whatever the back color is, it stays.
 
I am having some problems with TransparentKey as well. I wrote a simple clock program, set the transparentkey, and run the program. I have 2 indentical computers, it works (is transparent) on one, but not the other. Have never been able to figure that out.

Becca

Somtimes, the easy answer is the hardest to find. :)

Still under construction ...
 
This is really annoying, because you have to spawn paint events for every sub-form! Can this really be what the designers intended? The usefulness of being able to see your desktop through your application is minimal, if you ask me. And being able to stack transparent forms seems really important... hmmm....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top