views:

274

answers:

1

Hello all,

Long title, but simple problem.

I am trying to let a window stick to the destop (or pin), I can do this like this:

    [DllImport("User32.dll")]
    static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    [DllImport("user32.dll")]
    static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        IntPtr pWnd = FindWindow("Progman", null);
        pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SHELLDLL_DefVIew", null);
        pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", null);
        IntPtr tWnd = this.Handle;
        SetParent(tWnd, pWnd);

This works fine, but I cannot change transperancy or opacitiy.

I can use CreateWindowEx to create a nice transparent window layered, but then this methode does not work anymore to pin it to the desktop!

Anybody know's how this can be done?

Thank!

+2  A: 

Only top-level windows can be created as layered. With your approach, you are creating a child window to the desktop window, hence it can't be layered.

It might be better if you try to explain what you mean by "sticking"/"pinning" a window to the desktop. I assume that you want to set the window at particular position on the desktop and keep it always there, but there must be something more to it which I am missing. Otherwise, why wouldn't just positioning the window at particular coordinates on the screen not work for you?

Franci Penov
I would like to have my form to "stick" to the deskopt, so if I minimize everything, it will still be visible, it had to be part of the desktop screen, much like the gadgets sidebar! This works fine with posted code, but transperancy will not work in that way, so I am looking for a solution that do both! :)
Rogier21