Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
beluga - 20 Jul 2006 08:05 GMT
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
G Himangi - 21 Jul 2006 07:13 GMT
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
---------

> Hi,
>
[quoted text clipped - 13 lines]
>
> John
beluga - 21 Jul 2006 18:06 GMT
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.

> The windows are the same - .Net WinForms is just a wrapper around the
> Win32 API.
[quoted text clipped - 28 lines]
>>
>> John

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.