locked
show desktop RRS feed

  • Question

  • hello there

    is there a way that I can show the desktop in my form ??

     

     

    Monday, September 17, 2007 1:49 PM

Answers

  • Clint:

     

    I can give you an Idea, if you find how to apply the "Opacity" only to the form, not the Window if you understand what I mean(Title bar and Windows Border), you can apply it with Opacity = 0.

     

    Lamentably if you use it for ex.

     

    Me.Opacity = 0

     

    It will work for the entire window

     

    I hope this can be used.

     

    Regards,

    Monday, September 17, 2007 4:02 PM
  •  

    Right so use system.draw to a polgon of a color the having the opacity set to minium. Controls generally do not support this but I think system.drawing does. I may be mistaken in this and if I am, throw away this entire post. If it does, if you get a region of your form to have an opacity = o - that will expose the desktop in many more ways than just visually and this is a security feature. Any regions on a form, having a opacity of zero, reach through to whatever is below the form precluding the running of invisible forms. Of course you receive no form events etc in the transparent  region.

     

     

    Monday, September 17, 2007 5:22 PM
  • I have a MUCH easier solution. First, make a panel. Make it take up the space you want the desktop to appear. Next, set the" BackColor" of that panel to a color you have no where else in your form(EX: Light Pink). Once you have done that, set the property "TransparencyKey" on your form to the EXACT same color as the color of the panel. That's it! The result is a form with a hole in it where you can see the desktop.
    I hope I was clear enough, if you need me to explain in more detail I'd be glad to.
    Monday, September 17, 2007 10:49 PM
  • Clint

     

    Here's a different way to do it.  It has a problem though in that you lose the XP styles on the form - I don't know how to get round that yet.

     

    Public Class Form1

    Dim P As New Panel

    Dim WithEvents B As New Button

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    P.Height = 60

    P.Dock = DockStyle.Top

    P.BackColor = Color.Yellow

    B.SetBounds(20, 20, 100, 20)

    B.Text = "Show Desktop"

    Controls.Add(P)

    P.Controls.Add(B)

    End Sub

    Private Sub B_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles B.Click

    Static ShowingDesktop As Boolean

    If ShowingDesktop Then

    Me.Region = Nothing

    ShowingDesktop = False

    B.Text = "Show Desktop"

    Else

    Dim Rgn As New Region()

    Rgn.Exclude(New Rectangle(4, P.Bottom + SystemInformation.CaptionHeight + 4, Width - 8, Height - 8 - P.Bottom - SystemInformation.CaptionHeight))

    Me.Region = Rgn

    ShowingDesktop = True

    B.Text = "Hide Desktop"

    End If

    End Sub

    End Class

    Tuesday, September 18, 2007 2:44 PM
  • For the WMV problem, can't you just set "TransparencyKey" to "Nothing"? ( Me.TranparencyKey = Nothing)

    Tuesday, September 18, 2007 7:19 PM

All replies

  • Use PrintScreen to capture it.  Save it as a file and display the file on your form.

     

    I somehow just know that isn't what you wanted

     

    Monday, September 17, 2007 1:56 PM
  • afraid not dave

    that would just be a bitmap....I want the actual desktop....with icons....can that be done

    something like process.start

    I thought this would do

    Process.Start(My.Computer.FileSystem.SpecialDirectories.Desktop)

    but that just opens the folder

    any ideas ??

     

    Monday, September 17, 2007 2:06 PM
  • Not really I'm afraid.

     

    Just done a quick Google and the impression I get is that it isn't going to be easy!  There doesn't seem to be anything in managed code to help.

     

    Monday, September 17, 2007 3:34 PM
  • ok dave

    thanks anyway

    clint

    Monday, September 17, 2007 3:49 PM
  • Clint:

     

    I can give you an Idea, if you find how to apply the "Opacity" only to the form, not the Window if you understand what I mean(Title bar and Windows Border), you can apply it with Opacity = 0.

     

    Lamentably if you use it for ex.

     

    Me.Opacity = 0

     

    It will work for the entire window

     

    I hope this can be used.

     

    Regards,

    Monday, September 17, 2007 4:02 PM
  • yes, thats a good idea....only trouble is I have a top and bottom panel

    which I do not want to hide

    I would like to place the desktop between the panels

    thanks for the thought

    clint 

    Monday, September 17, 2007 4:48 PM
  •  

    Right so use system.draw to a polgon of a color the having the opacity set to minium. Controls generally do not support this but I think system.drawing does. I may be mistaken in this and if I am, throw away this entire post. If it does, if you get a region of your form to have an opacity = o - that will expose the desktop in many more ways than just visually and this is a security feature. Any regions on a form, having a opacity of zero, reach through to whatever is below the form precluding the running of invisible forms. Of course you receive no form events etc in the transparent  region.

     

     

    Monday, September 17, 2007 5:22 PM
  • ok thanks renee

    I created this before I seen your post.....

     

    because of my limited programming knowledge ..I have devised a neat little trick

    form1 has a nice panel on the top with some  buttons...music player, internet, etc...plus a desktop button

    it is about 1 inch high and full width

    so I have created a new form and made it the same size as  this form1 panel

    I then coppied the panel to form 2

    so form1 and form2 are now the same, except form1 is full screen and form2 is just 1 inch high and posistioned at the top

    of the screen

    so now when I click the desktop button

    form1.opacity=0

    form2.show....I can now see the desktop plus my form2 at the top of the screen.....

    I then click the desktop button on form2

    form1.opacity=100

    me.close

    and I am back to my application

    hows that for a trick......easy

     

    edit......best to use show and hide...rather than opacity

    Monday, September 17, 2007 6:22 PM
  • I have a MUCH easier solution. First, make a panel. Make it take up the space you want the desktop to appear. Next, set the" BackColor" of that panel to a color you have no where else in your form(EX: Light Pink). Once you have done that, set the property "TransparencyKey" on your form to the EXACT same color as the color of the panel. That's it! The result is a form with a hole in it where you can see the desktop.
    I hope I was clear enough, if you need me to explain in more detail I'd be glad to.
    Monday, September 17, 2007 10:49 PM
  • vbvb66

    thanks for that...works nicely

    that is really clever, wish I had thought of it

    cheers

    clint

     

     

    EDIT.......

    this works great with a panel or with just the form transparency key......except for this

     

    I have a webbrowser button..which opens a web page.....

    the web page has a windows media player embedded in the page...showing a wmv file

     

    when the transparency key is set.....the wmv file wont show......the screen is blank....

    all other web pages are ok.....

     

    I have tried setting the key to another color, but its still no good... 

     

    help ????????????????????

    Tuesday, September 18, 2007 7:53 AM
  • Clint

     

    Here's a different way to do it.  It has a problem though in that you lose the XP styles on the form - I don't know how to get round that yet.

     

    Public Class Form1

    Dim P As New Panel

    Dim WithEvents B As New Button

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    P.Height = 60

    P.Dock = DockStyle.Top

    P.BackColor = Color.Yellow

    B.SetBounds(20, 20, 100, 20)

    B.Text = "Show Desktop"

    Controls.Add(P)

    P.Controls.Add(B)

    End Sub

    Private Sub B_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles B.Click

    Static ShowingDesktop As Boolean

    If ShowingDesktop Then

    Me.Region = Nothing

    ShowingDesktop = False

    B.Text = "Show Desktop"

    Else

    Dim Rgn As New Region()

    Rgn.Exclude(New Rectangle(4, P.Bottom + SystemInformation.CaptionHeight + 4, Width - 8, Height - 8 - P.Bottom - SystemInformation.CaptionHeight))

    Me.Region = Rgn

    ShowingDesktop = True

    B.Text = "Hide Desktop"

    End If

    End Sub

    End Class

    Tuesday, September 18, 2007 2:44 PM
  • cheers dave, I'll have to play around with this

    take me a day or 2....will let you know how it goes

    clint

    Tuesday, September 18, 2007 3:17 PM
  • Hi dave

    you are a genius,I have condensed your code into this.

    I dont know if the hi-lighted line is right but it gives me what I want, perhaps you will edit it for me..

    I just want a box on the left to show desktop icons..the top and bottom panels are ok

    I dont understand this line ..

    ps it works perfectly..........thank you

     

    Private Sub Label30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label30.Click

    Static ShowingDesktop As Boolean

    If ShowingDesktop Then

    Me.Region = Nothing

    ShowingDesktop = False

    'B.Text = "Show Desktop"

    Else

    Dim Rgn As New Region()

    Rgn.Exclude(New Rectangle(4, Me.Left + SystemInformation.CaptionHeight + 42, Width - 1028, Height - 126 - SystemInformation.CaptionHeight))

    Me.Region = Rgn

    ShowingDesktop = True

    'B.Text = "Hide Desktop"

    End If

    End Sub

    Tuesday, September 18, 2007 7:15 PM
  • For the WMV problem, can't you just set "TransparencyKey" to "Nothing"? ( Me.TranparencyKey = Nothing)

    Tuesday, September 18, 2007 7:19 PM
  • Clint

     

    The only comment really is that you should try and avoid the "Magic Numbers" in the rectangle dimensions - and yes I know I used some.

     

    The aim is to define in the rectangle the area which you want to appear as a hole.  You should do this by reference to other control's properties or the form properties.  For instance I presume the 42 is the height of one of your panels.  If so you should use Panel.Height rather than the design value.  Similarly Width - 1028 could possibly be reference to another control.  If you do this then if (when?) you change the dimensions of some of the controls you don't have to revisit all your code to adjust for the new sizes.

     

    It could still be that vbvb66's solution is easier (see his last post) but knowing how to control the region is a useful tool to have in your bag.

     

    Tuesday, September 18, 2007 10:44 PM
  • thanks guys

    both options work perfectly....

     

    vbvb66...ur option is best for me...just to show desktop icons

     

    dave...ur option is fantastic, althought a bit complicated for a novice

    it is a nice tool to have...I will experiment with it

    cheers

    clint

    Wednesday, September 19, 2007 6:21 AM
  • Thanks.
    Wednesday, September 19, 2007 8:31 PM