VB.Net Desktop

Pleh

Active member
Joined
Sep 5, 2006
Messages
36
Programming Experience
3-5
I was thinking of putting this thread in Drawing but as its a bit vague i put it here instead, i hope thats ok :)

I am writing a shell replacement in VB.Net and i would like to have an extremely customisable desktop. I guess im just after some advice on what would be the best approach...

Im thinking of just using a boarderless window that will be fullscreen and allways behind other windows, then create a desktop object control that will basicly be a container with size handles that the user can use to move the object around at runtime. Then i will just inherit this control and use it as a base for my "widgets".

Then i was thinking of just drawing an image on the back of the "desktop" window. the problem comes with transparency, transparency can slow things down quite alot, should i just make the entire desktop redraw then redraw all its controls every time it needs to paint, or do you think if i start with a usercontrol as the base for my desktop object control and set its back color to transparent that will be better?

I need to be able to drag the desktop objects around without drawing problems too.

Any thoughts on any of that?
And is anyone interested in helping with this project when i make it open source?
 
I think that a borderless window would be more appropriate here, drawing an image on the desktop is gonna get really messy when it comes for a repaint and i reckon it will flicker like crazy. The first option seems the most .Net way to go.
Re-painting and flickering won't be a problem this way because you can specify the region to invalidate and should you need to invalidate the entire form and it's controls double buffering will take care of this.
 
Good thinking, double buffering will help reduce flicker when im dragging, i think i will try that approach.

Anyone know how to make a window allways stay at the bottom without using the NOACTIVATE message?
 
This may not be what you want exactly, but if you use the AddOwnedForm method then it will always be at the bottom. There most likely is an API way but i'd need to look into it.
 
I think ive got it, this seemed to work for the desktop control...

VB.NET:
[SIZE=2][COLOR=#0000ff]Public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] Desktop[/SIZE]
[SIZE=2][COLOR=#0000ff]Protected [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overloads [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overrides [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ReadOnly [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Property[/COLOR][/SIZE][SIZE=2] CreateParams() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.CreateParams[/SIZE]
[SIZE=2][COLOR=#0000ff]Get[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] cp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] CreateParams = [/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].CreateParams[/SIZE]
[SIZE=2]cp.ExStyle = WS_EX_TOOLWINDOW[/SIZE]
[SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][SIZE=2] cp[/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Get[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Property[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overloads [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Show()[/SIZE]
[SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Handle = IntPtr.Zero [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].CreateControl()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]SetParent([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Handle, IntPtr.Zero)[/SIZE]
[SIZE=2]ShowWindow([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Handle, 1)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]

Now to get the double buffering and transparency and stuff working
 
DoubleBuffering is a piece of cake in .Net.

VB.NET:
SetStyle(ControlStyles.AllPaintingInWMPaint,True)
Setstyle(ControlStyles.DoubleBuffer, True)
Setstyle(ControlStyles.UserPaint,True)
In the forms constructor.
 
I just tried that code sample and it flickers worse than without it :s am i missing something?

I need to be able to draw an image over another image and be able to drag it around without flickering.

Also when its not in design mode i need to be able to keep redrawing to a minimum because its going to be visible all the time as its the desktop and i dont want rendering the desktop to slow down the system.

Maby i should use a buffer for this too?
 
Last edited:
Mmmm, it is possible that beacuse your are using the ShowWindow API it is interfering with the control style, style bits. It maybe that you need to write a new doublebuffer class for this.
 
I think your right, I tried doing a manual double buffer and it works better now, also i used the PaintDesktop API to draw the background image instead of just setting the form background image, and now it runs alot smoother too.
 
Back
Top