[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

How to find HWIND of Windows from Handle in C#?

Dear Experts

I need to find a HWND for Windows Form (NET Framework 2.0)   from this.Handle. How to do it ? More, I need to get in variable in IWin32Window . I need this because of use third part components and I need to pass it.
To be more clear,  I do not want to use find procedure via title of Windows, I believe there other way.

Thanks.
0
dvplayltd
Asked:
dvplayltd
3 Solutions
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"this.Handle" is the HWND but in IntPtr form...

You can simply convert it to an int if that is what you are looking for:

    int HWND = this.Handle.ToInt32();

I suspect there's more to it than this though!

Can you explain in MORE DETAIL please?...
0
 
Miguel OzSoftware EngineerCommented:
If your third part components are .net, then you can pass the the form instance itself.
For example I use the following construct a lot:
  form.ShowDialog(parentForm)
where parentForm is a valid from instance. Form supports IWin32Window interface.
0
 
Jaime OlivaresCommented:
it is as easy as:

IWin32Window hwnd = yourform.Handle;
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now