473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Control from HWND

Hello

I have just started using .NET and C# from a c++ background using
win32. Now i want to do something that i used to do, without using the
win32 API.

I use Spy++ to get a HWND from another application in hex form from a
RICHEDIT control.

now i want to turn this hex value (HWND) into a control in C#.
Why doesn't this work?

IntPtr ptr = new IntPtr(0x00020A92);
Control control = System.Windows.Forms.Control.FromChildHandle(ptr);

Is there some other way to do this?? i don't wanna use the win32 API!

Thanks in advance!

Feb 28 '06 #1
1 12257
MultiMarine,

You can get a control associated with given HWND only if the control has
been created in the application from a WindowsForm class. When you create a
control the framework keeps map between HWNDs and control objects and uses
this map to when Control.FromChildHandle is called.
You cannot create a control object form a random window by its HWND.

..NET provides NativeWindow class that can be attached to any HWND and can be
used for windows subclassing.
--
HTH
Stoitcho Goutsev (100)

"MultiMarine" <mu***********@hotmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Hello

I have just started using .NET and C# from a c++ background using
win32. Now i want to do something that i used to do, without using the
win32 API.

I use Spy++ to get a HWND from another application in hex form from a
RICHEDIT control.

now i want to turn this hex value (HWND) into a control in C#.
Why doesn't this work?

IntPtr ptr = new IntPtr(0x00020A92);
Control control = System.Windows.Forms.Control.FromChildHandle(ptr);

Is there some other way to do this?? i don't wanna use the win32 API!

Thanks in advance!

Feb 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
7
by: tlviewer | last post by:
hello, If you run the Mainboard monitor, speedfan, here is an ActivePython script to force automatic fan control.         http://www.almico.com/speedfan.php It's a great example of...
0
by: Sam Barham | last post by:
I have a ListView control, for which I have overwritten the WndProc method to gain access to the WM_PAINT message and generate my own OnPaint and OnPaintBackground messages, in order to colour the...
1
by: Ziggy | last post by:
Please excuse this elementary question...but I am just dumb.... I have taken a simplistic Dialog Box and added a Progress Control. When I did that, my Dialog Box was no longer able to intialize...
0
by: sukhpalsingh | last post by:
With this little DLL you can embed either Mozilla ActiveX Browser Control or MSIE by just calling it's EmbedBrowser(HWND hwnd, int i) function. 0 = Mozilla Activex Browser Control and 1 = MSIE. ...
2
by: mmacrobert | last post by:
We have an MFC application mixed with a few .NET controls. I would like to be able to render the content of a .NET control to an MFC device context - specifically a printing device context. We...
2
by: Danny | last post by:
Hi I want to be able from my csharp button to start an application ( which I can do) and then somehow send a message to the win32 application that says "press the button" The win32...
5
by: Tom Gur | last post by:
Hi, I was wondering how do I get control over a window (Win32). to be more specific, I need to find a handle to a window of a certain program and minimize the window.
2
by: qhimq | last post by:
Hi, could someone tell me how to fix this? The edit control does not show up however the mouse changes around the position i want it to display. https://netfiles.uiuc.edu/qmitche2/www/tabs.exe ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.