Click here to Skip to main content
15,920,596 members
Home / Discussions / C#
   

C#

 
QuestionDraw a rectangle in a richtextbox? Pin
red2k3-Mar-03 2:25
red2k3-Mar-03 2:25 
AnswerRe: Draw a rectangle in a richtextbox? Pin
jtmtv183-Mar-03 6:39
jtmtv183-Mar-03 6:39 
Questionvoid* interop? Pin
Anonymous2-Mar-03 19:55
Anonymous2-Mar-03 19:55 
AnswerRe: void* interop? Pin
Jeff J2-Mar-03 21:16
Jeff J2-Mar-03 21:16 
GeneralRe: void* interop? Pin
Anonymous3-Mar-03 2:04
Anonymous3-Mar-03 2:04 
GeneralRe: void* interop? Pin
leppie3-Mar-03 7:06
leppie3-Mar-03 7:06 
GeneralRe: void* interop? Pin
Jeff J4-Mar-03 14:36
Jeff J4-Mar-03 14:36 
GeneralInterop - Marshaling nested structs Pin
Nathan Tran2-Mar-03 19:01
Nathan Tran2-Mar-03 19:01 
Hi,

I'm getting a System.ArgumentException trying to call the following
IActiveDesktop method:

STDMETHOD (AddDesktopItem)(THIS_ LPCCOMPONENT pcomp, DWORD dwReserved) PURE;

This is how I'm marshaling the call.

void AddDesktopItem(
[In, MarshalAs( UnmanagedType.LPStruct )] COMPONENT pcomp,
[In] int dwReserved
);

I believe the problem is with marshaling the COMPONENT structure. Could
some one point out to me if I'm marshaling the nested structures correctly.
Here is the original typedef for the struct and my c# attempt at marshaling
it.

typedef struct _tagCOMPONENT
{
DWORD dwSize; //Size of this structure
DWORD dwID; //Reserved: Set it always to zero.
int iComponentType; //One of COMP_TYPE_*
BOOL fChecked; // Is this component enabled?
BOOL fDirty; // Had the component been modified and not
BOOL fNoScroll; // Is the component scrollable?
COMPPOS cpPos; // Width, height etc.,
WCHAR wszFriendlyName[MAX_PATH];
WCHAR wszSource[INTERNET_MAX_URL_LENGTH]; //URL of the component.
WCHAR wszSubscribedURL[INTERNET_MAX_URL_LENGTH]; //Subscrined URL

DWORD dwCurItemState; // Current state of the Component.
COMPSTATEINFO csiOriginal;
COMPSTATEINFO csiRestored; // Restored state of the component.
}
COMPONENT;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode )]
public class COMPONENT
{
public int dwSize; // Size of the structure.
public int dwID; // Reserved. Set to zero.
public COMP_TYPE iComponentType;
[MarshalAs( UnmanagedType.Bool )]
public bool fChecked;
[MarshalAs( UnmanagedType.Bool )]
public bool fDirty;
[MarshalAs( UnmanagedType.Bool )]
public bool fNoScroll;
[MarshalAs( UnmanagedType.Struct )]
public COMPPOS cpPos;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 260 )]
public string wszFriendlyName;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 2083 )]
public string wszSource;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 2083 )]
public string wszSubscribedURL;
public ITEM_STATE dwCurItemState;
[MarshalAs( UnmanagedType.Struct )]
public COMPSTATEINFO csiOriginal;
[MarshalAs( UnmanagedType.Struct )]
public COMPSTATEINFO csiRestored;

}

StructLayout( LayoutKind.Sequential )]
public class COMPSTATEINFO
{
public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public ITEM_STATE dwItemState;
}

[StructLayout(LayoutKind.Sequential)]
public class COMPPOS
{
public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int izIndex;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResize;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResizeX;
[MarshalAs( UnmanagedType.Bool )]
public bool fCanResizeY;
public int iPreferredLeftPercent;
public int iPreferredTopPercent;
}

GeneralRe: Interop - Marshaling nested structs Pin
leppie3-Mar-03 7:38
leppie3-Mar-03 7:38 
GeneralRe: Interop - Marshaling nested structs Pin
Nathan Tran3-Mar-03 11:56
Nathan Tran3-Mar-03 11:56 
GeneralRe: Interop - Marshaling nested structs Pin
leppie4-Mar-03 7:03
leppie4-Mar-03 7:03 
GeneralHowto: image to byte array Pin
Smitha Nishant2-Mar-03 18:56
protectorSmitha Nishant2-Mar-03 18:56 
GeneralRe: Howto: image to byte array Pin
Jeff J2-Mar-03 21:26
Jeff J2-Mar-03 21:26 
GeneralRe: Howto: image to byte array Pin
Smitha Nishant2-Mar-03 22:10
protectorSmitha Nishant2-Mar-03 22:10 
General***capturing image from video*** Pin
henrykao2-Mar-03 18:37
henrykao2-Mar-03 18:37 
QuestionCan you use resources to embed a wav? Pin
jtmtv182-Mar-03 13:48
jtmtv182-Mar-03 13:48 
AnswerRe: Can you use resources to embed a wav? Pin
leppie3-Mar-03 8:02
leppie3-Mar-03 8:02 
GeneralRe: Can you use resources to embed a wav? Pin
jtmtv183-Mar-03 8:32
jtmtv183-Mar-03 8:32 
GeneralRe: Can you use resources to embed a wav? Pin
leppie4-Mar-03 6:57
leppie4-Mar-03 6:57 
GeneralAeru IRC is looking for developpers and artist Pin
Shock The Dark Mage2-Mar-03 12:46
Shock The Dark Mage2-Mar-03 12:46 
GeneralRe: Aeru IRC is looking for developpers and artist Pin
jtmtv183-Mar-03 19:17
jtmtv183-Mar-03 19:17 
GeneralRe: Aeru IRC is looking for developpers and artist Pin
Shock The Dark Mage5-Mar-03 15:47
Shock The Dark Mage5-Mar-03 15:47 
GeneralFlattening The TreeView... Pin
LokiSD2-Mar-03 10:26
LokiSD2-Mar-03 10:26 
GeneralRe: Flattening The TreeView... Pin
LokiSD3-Mar-03 7:42
LokiSD3-Mar-03 7:42 
GeneralRe: Flattening The TreeView... Pin
Furty4-Mar-03 1:49
Furty4-Mar-03 1:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.