how can i pass a bitmap from axtiveX written in vc++6 to c# project?  
Author Message
MICHELLE1





PostPosted: Wed Sep 19 10:33:59 PDT 2007 Top

Visual Studio C++ >> how can i pass a bitmap from axtiveX written in vc++6 to c# project?

hi every body
i have an activeX that written in vc++6
i want to passa bitmap from activeX to my project in C3.NET

how can i do that?

what shuld be the return type of activeX.

is it possible that in vc++6 return HBITMAP and in c# i catch it in
Image calss?

Visual Studio20  
 
 
Alex





PostPosted: Wed Sep 19 10:33:59 PDT 2007 Top

Visual Studio C++ >> how can i pass a bitmap from axtiveX written in vc++6 to c# project?
> hi every body
> i have an activeX that written in vc++6
> i want to passa bitmap from activeX to my project in C3.NET
>
> how can i do that?
>
> what shuld be the return type of activeX.
>
> is it possible that in vc++6 return HBITMAP and in c# i catch it in
> Image calss?

According to MSDN `Image' class has `FromHbitmap (IntPtr)'
method, which accepts a handle to a bitmap. Did you try it?

Alex
 
 
Mehdi





PostPosted: Wed Sep 19 22:57:56 PDT 2007 Top

Visual Studio C++ >> how can i pass a bitmap from axtiveX written in vc++6 to c# project?

> > hi every body
> > i have an activeX that written in vc++6
> > i want to passa bitmap from activeX to my project in C3.NET
>
> > how can i do that?
>
> > what shuld be the return type of activeX.
>
> > is it possible that in vc++6 return HBITMAP and in c# i catch it in
> > Image calss?
>
> According to MSDN `Image' class has `FromHbitmap (IntPtr)'
> method, which accepts a handle to a bitmap. Did you try it?
>
> Alex

it is true but how can i pass a pointer or hbitmap from activeX?

 
 
Alex





PostPosted: Thu Sep 20 04:13:16 PDT 2007 Top

Visual Studio C++ >> how can i pass a bitmap from axtiveX written in vc++6 to c# project?
>
> it is true but how can i pass a pointer or hbitmap from activeX?
>

You just return it as a return value from a function:

------ IDL file -----
interface IMyObject : IDispatch
{
...
HRESULT GetBitmap([out,retval] OLE_HANDLE* phBmp);
};
---------------------

----- CPP file -----
STDMETHODIMP CAtlMyObject::GetBitmap(OLE_HANDLE* phBmp)
{

HBITMAP hRet = ...

*phBmp = (OLE_HANDLE)hRet;

return S_OK;
}
--------------------

Alex
 
 
Mehdi





PostPosted: Fri Sep 21 23:11:09 PDT 2007 Top

Visual Studio C++ >> how can i pass a bitmap from axtiveX written in vc++6 to c# project?

>
> > it is true but how can i pass a pointer or hbitmap from activeX?
>
> You just return it as a return value from a function:
>
> ------ IDL file -----
> interface IMyObject : IDispatch
> {
> ...
> HRESULT GetBitmap([out,retval] OLE_HANDLE* phBmp);};
>
> ---------------------
>
> ----- CPP file -----
> STDMETHODIMP CAtlMyObject::GetBitmap(OLE_HANDLE* phBmp)
> {
>
> HBITMAP hRet = ...
>
> *phBmp = (OLE_HANDLE)hRet;
>
> return S_OK;}
>
> --------------------
>
> Alex



in vc++6 we have hbitmap return type but return type of an activeX is
limitetd.

do you creat an MFC ActiveX yet?

one way that suggested to me is that i cast hbitmap to long and
return long from activeX and in my project

what's your idea about this way?


 
 
Alex





PostPosted: Sat Sep 22 04:04:31 PDT 2007 Top

Visual Studio C++ >> how can i pass a bitmap from axtiveX written in vc++6 to c# project?
> one way that suggested to me is that i cast hbitmap to
> long and
> return long from activeX and in my project
>
> what's your idea about this way?

Yes, this is widely accepted way to return a handle from
ActiveX.

Alex