Question Disabling BackGround in Windows Application Same as Windows Cardspace

rickjackson

New member
Joined
Sep 24, 2010
Messages
4
Programming Experience
1-3
Hello to all,

I am making a System Tray Application when i minimize my form its hide itself in the tray but whenever i click on the tray icon my form shows now when my form shows up i would like to disable my Background desktop same as CardSpace when its shows up. Any 1 knows how can i achive that ?

919q11.png


Regards
 
You can add this code to the form, it will add a semi-transparent form (with no borders or any content) that stays behind and fills entire desktop:
VB.NET:
Private WithEvents desktopFade As New Form

Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    With desktopFade
        .ShowInTaskbar = False
        .FormBorderStyle = Windows.Forms.FormBorderStyle.None
        .WindowState = FormWindowState.Maximized
        .BackColor = Color.Black
        .Opacity = 0.6
    End With
End Sub

Private Sub Form_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
    desktopFade.Show()
End Sub

Private Sub Form_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
    desktopFade.Close()
    desktopFade = Nothing
End Sub

Private Sub desktopFade_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles desktopFade.Activated
    Me.Activate()
End Sub
Also hide/show 'desktopFade' form along with the form when you do the NotifyIcon thing.

An additional note, same code can be used for modal dialogs (ShowDialog), but add owner to configuration (.Owner = Me.Owner) and specify the dialogs owner (calling dialog.ShowDialog(Me) for example). This will insert the 'fadeform' between the dialog caller and the dialog and thus also fade the calling form.
 
Back
Top