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 / December 2006

Tip: Looking for answers? Try searching our database.

How to create a managed container control capable of hosting controls using only their handles?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ObsesivelyCurious - 30 Dec 2006 00:12 GMT
I have a question for all you smart people out there.  I need to create
a managed windows forms control that can contain controls knowing only
their handles.  In fact, all it really needs to do is host a single
control in such a way that from the user's perspective it looks as if
only one control existed.  I need to accomplish this by using only the
handle of the hosted control.  I figured something like this could be
achieved by overriding WndProc of the container control and forwarding
(most of the) messages to the hosted control.  Of course, just blindly
forwarding all messages won't work, but just exactly which messages do
I need to forward?  And is this even the right thing to think about?

I know it may seem like a convoluted way of doing things, but there is
a good reason.  I could explain it at length, but here's just a brief
description.  Basically, I need to have the container control in one
app domain and the hosted control in another app domain.  Simply
getting a reference to the hosted control and trying to add it to the
container control breaks, because of the internal design of windows
forms, which doesn't work across app domains.  However, I know for a
fact that my hosted control can successfully be contained in an
unmanaged control (here, an IE sidebar), which must happen via the old
fashioned Win32 messages.  So I simply figured I could mimic this
behavior.

I would appreciate if anyone could share their insight.

Thanks,

Andrew
Mattias Sjögren - 30 Dec 2006 09:15 GMT
>Of course, just blindly
>forwarding all messages won't work, but just exactly which messages do
>I need to forward?  And is this even the right thing to think about?

You can use the SetParent Win32 API to move a control to a certain
parent. How that affects maanged controls, especially ones created in
different appdomains, I don't know.

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


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.