clint 2

hello there

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




Re: Visual Basic Express Edition show desktop

Dave299

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





Re: Visual Basic Express Edition show desktop

clint 2

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






Re: Visual Basic Express Edition show desktop

Dave299

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.





Re: Visual Basic Express Edition show desktop

clint 2

ok dave

thanks anyway

clint






Re: Visual Basic Express Edition show desktop

abasilis

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,






Re: Visual Basic Express Edition show desktop

clint 2

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






Re: Visual Basic Express Edition show desktop

ReneeC

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.






Re: Visual Basic Express Edition show desktop

clint 2

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






Re: Visual Basic Express Edition show desktop

vbvb66

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.





Re: Visual Basic Express Edition show desktop

clint 2

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






Re: Visual Basic Express Edition show desktop

Dave299

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





Re: Visual Basic Express Edition show desktop

clint 2

cheers dave, I'll have to play around with this

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

clint






Re: Visual Basic Express Edition show desktop

clint 2

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






Re: Visual Basic Express Edition show desktop

vbvb66

For the WMV problem, can't you just set "TransparencyKey" to "Nothing" ( Me.TranparencyKey = Nothing)