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 General / March 2006

Tip: Looking for answers? Try searching our database.

How to create a top level control?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Scott - 02 Mar 2006 10:51 GMT
I'd like to create a control that's top-level, i.e. parented by the
Windows desktop - something like a tooltip or menu.

When I call SetTopLevel( true ) in my control, Windows Forms (or is it
Windows?) creates a form and hosts my control in it!

There must be an easy way to create a true top-level control in Windows
Forms that isn't hosted/parented by a Windows Forms form.

Help!?

Cheers,

MikeS.
Nick Hounsome - 02 Mar 2006 11:12 GMT
> I'd like to create a control that's top-level, i.e. parented by the
> Windows desktop - something like a tooltip or menu.
[quoted text clipped - 4 lines]
> There must be an easy way to create a true top-level control in Windows
> Forms that isn't hosted/parented by a Windows Forms form.

Why must there?

By definition a control must be in a form. Tooltips are not controls they
are components (this is confused by the documentation that referes to them
as controls in various places) that manipulate a top level window/form to
which you have no direct access.

I suspect that what you want is simply to create a form and turn off the
borders and title (f.FormBorderStyle = FormBorderStyle.None)
Mike Scott - 02 Mar 2006 17:00 GMT
Hi Nick

I say "there must be an easy way" because, firstly, a form is a control,
as a component is a control. To Windows, they're all just window
handles. I've been programming Windows for 20+ years, since the Petzold
days. So I expect there must be a way to create a control that doesn't
have to be hosted in a form. Like I said, a *form* is a control that's
not hosted in a form, so there is a way.

If it's not easy, it must be because WinForms is going out of its way to
make it not easy, since there's no intrinsic reason why it should be hard.

Cheers,

MikeS.

>> I'd like to create a control that's top-level, i.e. parented by the
>> Windows desktop - something like a tooltip or menu.
[quoted text clipped - 14 lines]
> I suspect that what you want is simply to create a form and turn off the
> borders and title (f.FormBorderStyle = FormBorderStyle.None)
Chris Dunaway - 02 Mar 2006 18:01 GMT
Have you looked at the NativeWindow class?  Perhaps that will help you.
Nick Hounsome - 02 Mar 2006 18:53 GMT
Hi Mike,

A Component is NOT a Control.
Tooltip is a Component and therefore is not a control and has no handle.

Obviously the visual bit that it controls does have a handle but you can't
get at it and I see no reason to believe (other than simplicity) that it
isn't a form with the border turned off.

What about my suggestion of using a form with the border turned off?

Or NativeWindow if you must.

> Hi Nick
>
[quoted text clipped - 30 lines]
>> I suspect that what you want is simply to create a form and turn off the
>> borders and title (f.FormBorderStyle = FormBorderStyle.None)
Mike Scott - 03 Mar 2006 09:51 GMT
Hi Nick

Sorry, you're right about component. However, a form is a control and it
can be top-level.

As for using a form with no border - tried that! That's what my other
thread is about "Zero-sized form" that you've been participating in :-)

Ideally I just need a control, not a form though that obviously works.
This is partly a learning exercise - I can do it easily in native
Windows and I'm trying to figure out how to do it in WinForms.

Thanks for your help.

MikeS.

> Hi Mike,
>
[quoted text clipped - 42 lines]
>>> I suspect that what you want is simply to create a form and turn off the
>>> borders and title (f.FormBorderStyle = FormBorderStyle.None)

Rate this thread:







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.