|
|
|
date: Sat, 28 Jan 2006 16:18:13 +0000,
group: microsoft.public.platformsdk.com_ole
back
Re: WTF is a wireHBITMAP??
[
object,
uuid(blahblahblah),
pointer_default(unique)
]
interface IMyUIObject : IUnknown
{
[helpstring("method CalculateSize")] HRESULT CalculateSize([in] IMyDataObj *pData, [out, retval] SIZE *pSize);
[helpstring("method Draw")] HRESULT Draw([in] IMyDataObj *pData, [in] HBITMAP hBitmap, [out,retval] VARIANT_BOOL *pResult);
};
IMyDataObj is a dual, dispatch derived interface defined in the same library. It's just got a load of get/put functions.
HDC hDc=::GetDC(m_hWnd);
HBITMAP bitmap=CreateCompatibleBitmap(hDc, bitmapsize.cx, bitmapsize.cy);
if(SUCCEEDED(lpMyUIObj->raw_Draw(lpBarData, bitmap, &vtbool)) // c2664
{
// Do some shit
}
::ReleaseDC(m_hWnd, hDc);
error C2664: 'IMyUIObj::raw_Draw' : cannot convert parameter 2 from 'HBITMAP' to 'wireHBITMAP'
// This is what is in the imported lib.tlh in the debug folder of the client app:
struct __declspec(uuid(blahblahblah))
IMyUIObj : IUnknown
{
//
// Wrapper methods for error-handling
//
struct tagSIZE CalculateSize (
struct IMyDataObj * pData );
VARIANT_BOOL Draw (
struct IMyDataObj * pData,
wireHBITMAP hBitmap );
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall raw_CalculateSize (
/*[in]*/ struct IMyDataObj * pData,
/*[out,retval]*/ struct tagSIZE * pSize ) = 0;
virtual HRESULT __stdcall raw_Draw (
/*[in]*/ struct IMyDataObj * pData,
/*[in]*/ wireHBITMAP hBitmap,
/*[out,retval]*/ VARIANT_BOOL * pResult ) = 0;
};
date: Sat, 28 Jan 2006 22:03:40 +0000
author: Phil Da Lick!
Re: WTF is a wireHBITMAP??
"Phil Da Lick!"
wrote in message
news:43dbea34$0$82673$ed2619ec@ptn-nntp-reader03.plus.net
> [
> object,
> uuid(blahblahblah),
> pointer_default(unique)
> ]
> interface IMyUIObject : IUnknown
> {
> [helpstring("method CalculateSize")] HRESULT CalculateSize([in]
> IMyDataObj *pData, [out, retval] SIZE *pSize); [helpstring("method
> Draw")] HRESULT Draw([in] IMyDataObj *pData, [in] HBITMAP hBitmap,
> [out,retval] VARIANT_BOOL *pResult); };
> // This is what is in the imported lib.tlh in the debug folder of the
> client app:
Non automation compatible interfaces are not correctly represented in
type libraries. There is no point even putting them there. #import does
not handle them correctly. You need to use the .h file generated by MIDL
from the original IDL file.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Sun, 29 Jan 2006 12:26:26 -0500
author: Igor Tandetnik
Re: WTF is a wireHBITMAP??
Igor Tandetnik wrote:
> "Phil Da Lick!"
> wrote in message
> news:43dbea34$0$82673$ed2619ec@ptn-nntp-reader03.plus.net
>
>>[
>>object,
>>uuid(blahblahblah),
>>pointer_default(unique)
>>]
>>interface IMyUIObject : IUnknown
>>{
>>[helpstring("method CalculateSize")] HRESULT CalculateSize([in]
>>IMyDataObj *pData, [out, retval] SIZE *pSize); [helpstring("method
>>Draw")] HRESULT Draw([in] IMyDataObj *pData, [in] HBITMAP hBitmap,
>>[out,retval] VARIANT_BOOL *pResult); };
>>// This is what is in the imported lib.tlh in the debug folder of the
>>client app:
>
>
> Non automation compatible interfaces are not correctly represented in
> type libraries. There is no point even putting them there. #import does
> not handle them correctly. You need to use the .h file generated by MIDL
> from the original IDL file.
OK, I've now removed the #import for the library in question, and substituted it with a #include the generated .h file in stdafx.h. I then had to
include the _i.c genrated file for the IIDs and CLSIDs. That didn't work until i changed the properties for that item to not use precompiled headers.
All is now well but I was wondering whether this is the "proper" approach - isn't #import the preferred method???!
date: Sun, 29 Jan 2006 19:15:04 +0000
author: Phil Da Lick!
Re: WTF is a wireHBITMAP??
"Phil Da Lick!"
wrote in message
news:43dd1756$0$6966$ed2619ec@ptn-nntp-reader02.plus.net
> Igor Tandetnik wrote:
>> "Phil Da Lick!"
>> wrote in message
>> news:43dd142e$0$3634$ed2e19e4@ptn-nntp-reader04.plus.net
>>
>>> All is now well but I was wondering whether
>>> this is the "proper" approach - isn't #import the preferred
>>> method???!
>>
>>
>> Once again - #import only works for automation compatible
>> interfaces. If you need to use one that's not automation compatible,
>> you have to do it the old-fashioned way.
>
> Once again (:)) Is what I've done the "old fashioned way"?
Yes, that's the good old way - define your interface in IDL, compile
with MIDL, use the generated .h file.
A variation on what you did is to #include an _i.c file (in exactly one
..cpp or .c file in your project) rather than adding it to the project.
Saves the need to muck with precompiled headers. The way you did it is
fine, too.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Sun, 29 Jan 2006 14:54:02 -0500
author: Igor Tandetnik
|
|