Solved

How to insert a .NET control into a non-.NET NativeWindow ?

Posted on 2004-09-09
4
588 Views
Last Modified: 2012-05-05
I'm writing an Office Add-in in C#.
Using Automation, I get the Handle of the main window of the application in which the Add-in is running (in my case, PowerPoint).
I can then navigate the Child windows, hook into message loops and can create additional Windows using the NativeWindow class

But

I would like to be able to create a .NET control and position it into the application. The problem is that I have non-.NET handles and when I try to call Control.FromHandle(handle), it returns null. Then I can't assign a parent to my .NET control so it's not displayed.

So How do I assign a .NET control to a non-.NET parent window ?

Thanks

Marc
0
Comment
Question by:mridey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Author Comment

by:mridey
ID: 12023095
I found a solution on the dotnet247 forum.
After I create the .Net control, I call SetParent Win32 using:

\\\
[DllImport("USER32.DLL")]
private static extern IntPtr SetParent(
IntPtr hWndChild, // handle to window
IntPtr hWndNewParent // new parent window
);
///

That work.

If you know anything nicier, I'll still award the points.
0
 
LVL 8

Expert Comment

by:Razzie_
ID: 12024935
I don't even think there is another way to do that, although I could be wrong. Might just ask to get your points refunded in the community TA :)
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12269943
PAQed - no points refunded (of 500)

Computer101
E-E Admin
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question