views:

191

answers:

1

I have an application that I want to stick to the desktop. Stick to the desktop means that every time that someone click windows+D or the show desktop icon the desktop will appear with the application on it.

The user can locate the application on the desktop and change the location at any time but it always remains on the desktop.

We manage to do it on XP by setting the application’s parent to be the desktop using the winAPI methods SetParent (this .Handle, FindWindow ( "Progman " , null ));.

On Vista we manage to stick it to the desktop, whenever the desktop gets focus, it draws a gray background around we window. this background doesn't disappear when my window is moved, leaving ugly squares on the desktop. when I click Windows+D they all vanish. Note that this doesn't happen on XP at all.

The client is based on .NET 3.0 and WPF .

Any idea why it happens and how to solve it?

A: 

use the following code and pass the window handle to the function while form load hope fully this resolves your problem

public void SetFormOnDesktop(IntPtr hwnd) {  
IntPtr hwndf = hwnd;  
IntPtr hwndParent = FindWindow("ProgMan", null);  
SetParent(hwndf, hwndParent);  
}
JKS