Solved

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

Posted on 2010-09-20
3
257 Views
Last Modified: 2013-12-16
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
Comment
Question by:dvplayltd
3 Comments
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 100 total points
ID: 33720808
"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
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 300 total points
ID: 33721381
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
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 100 total points
ID: 33722039
it is as easy as:

IWin32Window hwnd = yourform.Handle;
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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