Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Form / Control as part of the desktop window

12 views
Skip to first unread message

Rolf Welskes

unread,
Jan 21, 2007, 9:54:10 PM1/21/07
to
Hello,
I have the following problem:

I have a control or form what ever.

I want that this is a part of the desktop window.

Means all other normal windows on the dektop are over my application.

I have tried to solve it with a little c++, windows sdk, but do not find a
solution.

I thought I have the control ctrl. and write:

MyControl ctrl = new MyControl();
ctrl.Create();
IntPtr h = ctlr.Handle,
CppHelper.SetOwnerToDesktopWindow(h);

CppHelper should be a small dll with c++ which uses windows functions to set
the control's owner to the desktop window.
But all I do it does not work.

Thank you for any help.
Rolf Welskes


Linda Liu [MSFT]

unread,
Jan 22, 2007, 5:34:32 AM1/22/07
to
Hi Rolf,

I am sorry that I may not understand what you want exactly. Based on my
understanding, you'd like a control or a form behave like it is a part of
the desktop, i.e. it can not be minimised and is always located behind
other normal windows on the desktop. If I'm off base, please feel free to
let me know.

To tell you the truth, I haven't seen such a behavior of a control/form
except the Gadgets in Windows Sidebar in Windows Vista yet.

Do you mean you want your contol/form to behave like Gadgets? If so, you
may visit the following link to get started:

'Gadget Development Overview '
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sidebar/sid
ebar/overviews/gdo.asp

If my suggestion is not what you want, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Rolf Welskes

unread,
Jan 22, 2007, 11:11:18 AM1/22/07
to
Hello,
thank you for your informations.
you understand right, but the solution is not what I want, because it must
run under
all windows systems.

I have an application of someone, downloaded (Calendar), which simple is
part of the desktop
means all other windows are over this application.
If I could set the owner of the control / form to the desktop window this
should work.
But this is not possible under dot net (1.1), because the owner must be a
.net control
and the desktop window is not available under dot net (1.1).
Under c++ it is possible to have the handle of the control and the desktop
window,
but how to set the desktop the owner of the control in c++ / windows
gui/sdk?

Thank you for any help.
Rolf Welskes

"Linda Liu [MSFT]" <v-l...@online.microsoft.com> schrieb im Newsbeitrag
news:vUgb2DhP...@TK2MSFTNGHUB02.phx.gbl...

Linda Liu [MSFT]

unread,
Jan 23, 2007, 6:27:33 AM1/23/07
to
Hi Rolf,

Thank you for your prompt response.

This is a quick note to let you know that I am researching on this issue
and will get it back to you ASAP.

I appreciate your patience.

Linda Liu [MSFT]

unread,
Jan 25, 2007, 3:54:34 AM1/25/07
to
Hi Rolf,

Sorry for my delayed reply.

You're in the right direction on attempting to set the desktop the parent
of the your form to embed your form as a part of the desktop.

I use spy++ to capture the desktop window and found that it is comprised of
3 sub windows. They're SysListView32, SHELL_DefView and Progman from
outside to inside. You could set any of these 3 sub window as the parent
window of your form.

The only difference is that if you set the SysListView32 as the owner, when
your form is minimized, it still stays on the desktop. On the contrary, if
you set the SHELL_DefView or Progman as the owner, when you minimize your
form, it becomes invisible. I suggest that you choose the SysListView32 as
the parent window.

To set a window as the parent window of another window, we could use the
Win32API -- SetParent.

The following is a sample.

using System.Runtime.InteropServices;

public partial class Form1 : Form
{
[DllImport("user32.dll")]
static extern private IntPtr FindWindow(string lpClassName,
string lpWindowName);
[DllImport("user32.dll")]
static extern private IntPtr GetWindow(IntPtr hWnd, int uCmd);
[DllImport("user32.dll")]
static extern private IntPtr SetParent(IntPtr hWndChild, IntPtr
hWndNewParent);

const int GW_CHILD = 5;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
IntPtr progmanhwnd = FindWindow("Progman", null);
IntPtr shellhwnd = GetWindow(progmanhwnd, GW_CHILD);
IntPtr folderhwnd = GetWindow(shellhwnd, GW_CHILD);

SetParent(this.Handle, folderhwnd);

}
}

Please try my suggestion and let me know the result.


Sincerely,
Linda Liu
Microsoft Online Community Support

Rolf Welskes

unread,
Jan 29, 2007, 8:12:14 AM1/29/07
to
Hello,
thank your for your informations.
It works fine.
Thank you again and best regards
Rolf Welskes

"Linda Liu [MSFT]" <v-l...@online.microsoft.com> schrieb im Newsbeitrag

news:2RcT15FQ...@TK2MSFTNGHUB02.phx.gbl...

0 new messages