Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / January 2007

Tip: Looking for answers? Try searching our database.

Form / Control as part of the desktop window

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rolf Welskes - 22 Jan 2007 02:54 GMT
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] - 22 Jan 2007 10:34 GMT
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 - 22 Jan 2007 16:11 GMT
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

> Hi Rolf,
>
[quoted text clipped - 40 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Linda Liu [MSFT] - 23 Jan 2007 11:27 GMT
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.

Sincerely,
Linda Liu
Microsoft Online Community Support
Linda Liu [MSFT] - 25 Jan 2007 08:54 GMT
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
This posting is provided "AS IS" with no warranties, and confers no rights.
Rolf Welskes - 29 Jan 2007 13:12 GMT
Hello,
thank your for your informations.
It works fine.
Thank you again and best regards
Rolf Welskes

> Hi Rolf,
>
[quoted text clipped - 59 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.