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 / .NET Framework / Interop / June 2004

Tip: Looking for answers? Try searching our database.

Using window handles in managed code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Clyde - 02 Jun 2004 21:56 GMT
In a managed class implemented as a com object, I want to pass a window handle from the client into the com object and use it as the parent of a form shown as a dialog.   How can I convert the handle (passed as a long) into a IWin32Window object
Saurabh - 03 Jun 2004 10:19 GMT
IWin32Window is an interface so you will have to create a class which
implements this interface and then use this class for your stuff.

internal class MyNativeWindow : IWin32Window
{
private IntPtr m_MyHandle;

internal MyNativeWindow (long handle)
{
 m_MyHandle = new IntPtr(handle);
}

public System.IntPtr Handle
{
 get
 {
  return m_MyHandle;
 }
}
}

and when you want to show the dialog,

Form f = new YourForm(); //create your form

ParentWindow = new MyNativeWindow (<whatever handle value you have got>);
f.ShowDialog(ParentWindow);

HTH,

--Saurabh

> In a managed class implemented as a com object, I want to pass a window handle from the client into the com object and use it as the parent of a
form shown as a dialog.   How can I convert the handle (passed as a long)
into a IWin32Window object.
Clyde LeFevre - 03 Jun 2004 15:54 GMT
Thanks, that looks just what I need.

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.