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 / October 2004

Tip: Looking for answers? Try searching our database.

Hosting System.Windows.Forms.Form (instead of UserControl)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stanislav Simicek - 13 Oct 2004 14:11 GMT
I have an (ActiveX) UserControl hosted in MFC application. Because the
UserControl does not support main menu, which I need, I tried to host Form
directly, but MFC hosting (VC++ 6.0) reports a "Not Supported" exception
while attempting to set site. Does anyone know whether is possible to host
Form instead of UserControl? I have not found any differences in UserControl
and Form code (using Lutz Roeder's Reflector) that should have effect on
hosting behavior (both UserControl and Form are derived from
ContainerControl). Am I missing something important?
Stoitcho Goutsev \(100\) [C# MVP] - 16 Oct 2004 17:09 GMT
Hi Stanislav,

No form's cannot be hosted. Forms represent TopLevel windows. Top-level
widnows is the one used for application's main windows and are shown on the
taskbar, etc. Top-level windows cannot have parent's, but they might have
owners.
Child windows on the other hand is the ones that can be hosted. Child
windows, though, cannot have main menu. If you look at the Win32 API for
creating windows you'll see that the same paramether that is used to set
top-level window's main menu for the child windows is used to set the
control ID.

Form class has one proeprty TopLevel. When set to false the form can be
hosted by other form's. However, what the property does is it make the form
a child window thus, the form loses its main menu.

But you are right there is not much of difference between form's and user
controls. At the very end they are control's (windows). However they are
meant to serve different purposes.

The botton line: unless you don't use some third party menubar conrol you
cannot have  main menu on child control (window). Windows OS says so.

Signature

HTH
Stoitcho Goutsev (100) [C# MVP]

>I have an (ActiveX) UserControl hosted in MFC application. Because the
> UserControl does not support main menu, which I need, I tried to host Form
[quoted text clipped - 5 lines]
> hosting behavior (both UserControl and Form are derived from
> ContainerControl). Am I missing something important?
Stanislav Simicek - 18 Oct 2004 08:27 GMT
Thank you very much for the detailed information.

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.