473,327 Members | 2,103 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,327 software developers and data experts.

Handles and Memory Management

I have a Windows Form in .NET 2.0 who's handle (HWND) I need for use in
native C++ code. As I understand it, the handle from my windows form
control may change managed memory locations arbitarily, which in that
case will cause problems with my native code. Is there a way to tell
..NET to never change the memory location of my window handle?

I create my form like so:
MyForm^ foo = gcnew MyForm();

Thanks,

Gary
Feb 3 '06 #1
2 1024
"Gary Nastrasio" <ga***********@hotmail.com> wrote in message
news:Oi**************@TK2MSFTNGP14.phx.gbl...
I have a Windows Form in .NET 2.0 who's handle (HWND) I need for use in
native C++ code. As I understand it, the handle from my windows form
control may change managed memory locations arbitarily, which in that case
will cause problems with my native code. Is there a way to tell .NET to
never change the memory location of my window handle?


Not exactly. Your form may change locations in memory, but the HWND is an
opaque value that won't ever change during the lifetime of the form (or
anything derived from System.Windows.Forms.Control).

-cd
Feb 3 '06 #2
Hi Gary!
I have a Windows Form in .NET 2.0 who's handle (HWND) I need for use in
native C++ code. As I understand it, the handle from my windows form
control may change managed memory locations arbitarily, which in that
case will cause problems with my native code. Is there a way to tell
..NET to never change the memory location of my window handle?
A handle is just a value, and it is not bound to any memory location...
I create my form like so:
MyForm^ foo = gcnew MyForm();


You will get the hWnd with

foo->Handle
http://msdn2.microsoft.com/system.wi...ol.handle.aspx
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 3 '06 #3

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

Similar topics

11
by: Rohit | last post by:
Hi, Threads in the .NET Framework 1.1 (and possibly in 1.0 also) leak "Event" handles, by Event handles I mean Win32 Event handles which can be monitored using the ProcessExplorer from...
11
by: Rohit | last post by:
Hi, Threads in the .NET Framework 1.1 (and possibly in 1.0 also) leak "Event" handles, by Event handles I mean Win32 Event handles which can be monitored using the ProcessExplorer from...
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
5
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.