Groups | Blog | Home
all groups > dotnet interop > october 2003 >

dotnet interop : Mapping IDL Interface



Shawn
10/31/2003 8:34:33 AM
From the Platform SDK, for MMC. Please help mapping the
interface IToolbar for use with C#. I'm specifically
having problems with the AddButtons method, that accepts a
c-style array of MMCBUTTON structure.

IToolbar (from Platform SDK):
[
object,
uuid(43136EB9-D36C-11CF-ADBC-00AA00A80033),
pointer_default(unique)
]
interface IToolbar : IUnknown
{
[helpstring("Add and image to the toolbar")]
HRESULT AddBitmap([in] int nImages, [in] HBITMAP
hbmp, [in] int cxSize, [in] int cySize, [in] COLORREF
crMask );

[helpstring("Add an array of buttons to the
toolbar")]
HRESULT AddButtons([in] int nButtons, [in]
LPMMCBUTTON lpButtons);

[helpstring("Add a single button to the toolbar at
position nIndex")]
HRESULT InsertButton([in] int nIndex, [in]
LPMMCBUTTON lpButton);

[helpstring("Remove a button at the index")]
HRESULT DeleteButton([in] int nIndex);

[helpstring("Get an attribute of a button")]
HRESULT GetButtonState([in] int idCommand, [in]
MMC_BUTTON_STATE nState, [out] BOOL* pState);

[helpstring("Set an attribute of a button")]
HRESULT SetButtonState([in] int idCommand, [in]
MMC_BUTTON_STATE nState, [in] BOOL bState);
};

AddButton Method Documentation:

IToolbar::AddButtons
The IToolbar::AddButtons method enables a snap-in to add
an array of buttons to the toolbar.

HRESULT AddButtons(
int nButtons,
LPMMCBUTTON lpButtons
);

Parameters
nButtons
[in] Number of buttons in the array.
lpButtons
[in] Pointer to the MMCBUTTON structure containing
information necessary for creating a button on the
toolbar.
Return Values
S_OK
The buttons were successfully added.
E_INVALIDARG
The lpButtons parameter is NULL, nButtons is less than 1,
or one of the MMCBUTTON items has an invalid image index
or NULL button text or ToolTip text.

Thanks,
Mattias Sjögren
11/4/2003 12:51:24 AM
Shawn,

[quoted text, click to view]

I'd try

void AddButtons(int nButtons, [MarshalAs(UnmanagedType.LPArray)]
MMCBUTTON[] lpButtons);



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Shawn Ward
11/4/2003 9:02:33 AM

Thanks, that worked. I thought I had tried the solution at one point
without result.

Thanks, again.


*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button