Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Now I know a function in MFC dll
<br />
   CBitmap* GetPreBitmap();<br />

I Write some codes in C#
<br />
  [DllImport("some.dll")]<br />
  static extern IntPtr GetPreBitmap();<br />

Now I want put IntPtr to Image to display,Is there someone know how to do
Posted
Comments
Sergey Alexandrovich Kryukov 21-Feb-13 2:16am    
Are you seriously develop .NET with MFC? I'm just curious; it looks crazy to me... How much of progress, I wonder?
—SA

1 solution

I don't think it makes practical sense (I mean the whole idea: .NET + MFC), but in principle, you can. Here is how:
http://msdn.microsoft.com/en-us/library/k061we7x.aspx[^].

—SA
 
Share this answer
 
Comments
sum_and_sum 21-Feb-13 2:21am    
Yeah,I Know this function
I write some codes

1 public static Bitmap GetPrevBitmap()
2 {
3 IntPtr hBitmap = GetPreBitmap();
4 return Bitmap.FromHbitmap(hBitmap);
5 }
but in line 4 throw a exception: A generic error occurred in GDI+.
Sergey Alexandrovich Kryukov 21-Feb-13 2:25am    
This method does work.
Are you sure this is a valid bitmap handle? I don't know what is your GetPreBitmap().
—SA
sum_and_sum 21-Feb-13 19:05pm    
Can you give your codes for test? Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900