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 / February 2007

Tip: Looking for answers? Try searching our database.

Component needs a form's HWND

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mikesnoise@gmail.com - 14 Feb 2007 19:18 GMT
I am writing a class derived from Component that calls a Win32
function to display a dialog box. The Win32 function takes an HWND as
the parent window of the dialog box (for positioning the dialog over
the parent). How do I get the HWND of the form that it was dropped on?

Thanks,
-Mike-
ClayB - 14 Feb 2007 19:54 GMT
Try using

         IntPtr HWND = this.Handle; //this refers to the Form.

to see if this is what you need.

=============
Clay Burch
Syncfusion, Inc.
mikesnoise@gmail.com - 14 Feb 2007 20:08 GMT
> Try using
>
[quoted text clipped - 5 lines]
> Clay Burch
> Syncfusion, Inc.

I'm writing a class derived from Component. I want it to be able to
figure out the form's handle. The this keyword would be the Component,
not the form. In other words I don't want to expose a property to
specify the HWND -- I want this to be automatic like the
FileOpenDialog component.

-Mike-
Jeff Gaines - 14 Feb 2007 22:36 GMT
On 14/02/2007 in message
<1171483703.050238.145150@l53g2000cwa.googlegroups.com>

>>Try using
>>
[quoted text clipped - 13 lines]
>
>-Mike-

In cases like this I use a constructor that takes the parent form as a
parameter.

Signature

Jeff Gaines

mikesnoise@gmail.com - 14 Feb 2007 22:49 GMT
On Feb 14, 2:36 pm, "Jeff Gaines" <whitedra...@newsgroups.nospam>
wrote:
> On 14/02/2007 in message
> <1171483703.050238.145...@l53g2000cwa.googlegroups.com>
[quoted text clipped - 23 lines]
> --
> Jeff Gaines

Yeah, I could do that. But I'm really trying to emulate the
System.Windows.Forms.OpenFileDialog (I mistakenly called it the
FileOpenDialog component in a previous post). I looked in the
documentation and found that FileOpenDialog has two overloads of
ShowDialog: ShowDialog() and ShowDialog(IWin32Window). I guess
ShowDialog() probably calls GetOpenFileName() with a NULL owner HWND
while ShowDialog(IWin32Window) provides the parameter's HWND. I always
assumed that somehow the component was able to get the HWND of the
containing form. Does anyone know if ShowDialog() does any trick to
get the HWND or if it just passes NULL?

Thanks for all your help!
-Mike-
Stoitcho Goutsev (100) - 19 Feb 2007 16:34 GMT
Mike,

Common dialogs use GetActiveWindow API if parent window is not provided.

Signature

HTH
Stoitcho Goutsev (100)

> On Feb 14, 2:36 pm, "Jeff Gaines" <whitedra...@newsgroups.nospam>
> wrote:
[quoted text clipped - 39 lines]
> Thanks for all your help!
> -Mike-

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.