Can windowform surface be drawn by native window functions? (Win32 or MFC)

  • Thread starter Thread starter beluga
  • Start date Start date
B

beluga

Hi,

I am writing a .NET app that uses DLL libraries in native C++. Could anyone
tell me, is it possible for a windows created in .NET app using C#, then
pass the HWND handle of this window to a library that is written in native
MFC and from within this native library, it will do drawing on top of this
window? Somehow, it will crash the app when the library tries to draw that
..NET window surface. It says:

AccessViolationException: Attempted to read or write protected memory. This
is often an indication that other memory is corrupt.

I have even tried creating a window natively and then pass it to this
library and it also crashed. I'm curious, is a window created by .NET is
essentially the same as the one created by Win32 or MFC?

John
 
The windows are the same - .Net WinForms is just a wrapper around the Win32
API.

You can draw on WInForms controls via the Win32 API. In your OnPaint, use
the GetHdc method of Graphics class and use it to do your drawing via the
Win32 API, at the end call ReleaseHdc.


---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : Drop-In Explorer GUI Controls For Your Apps (.Net & ActiveX
Editions Available)
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions rapidly in .Net
 
Thanks for the answer. Yes, in fact I did try some drawing on the .NET
window using the traditional Win32 functions and it does work. However, what
puzzles me is why it crashes. I don't think I will be able to know this
until the library developer allows me to look into their codes on how they
do the drawings.
 
Back
Top