Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
N

Nathan Tran

@Nathan Tran
About
Posts
11
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Still having problems with IActiveDesktop
    N Nathan Tran

    Hi, I'm tackling the same IActiveDesktop problem and was wondering if you managed to work it out. I hope this gets through to your email. Nathan.

    C# data-structures help

  • Interop - Marshaling nested structs
    N Nathan Tran

    leppie, I don't need the DllImportAttribute since this COM method is being called through a c# mapped interface. Based on your suggestion to use IntPtr I have made the following changes to the code but I'm still getting System.ArgumentException. void AddDesktopItem( [In] IntPtr component, [In] int dwReserved ); [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; public int fChecked; public int fDirty; public int fNoScroll; 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; public COMPSTATEINFO csiOriginal; public COMPSTATEINFO csiRestored; } and the help method to copy the struct to unmanaged mem is as follows. public static IntPtr CreateByteBuffer( COMPONENT comp ) { IntPtr bufferPtr = Marshal.AllocCoTaskMem( Marshal.SizeOf( comp ) ); Marshal.StructureToPtr( comp, bufferPtr, true ); return bufferPtr; } Note: I have verified that the size of the struct to be correct. It is 8972 bytes to be exact. I have even checked the memory location of the IntPtr and all the relevant data is there. Any other suggestion? Nathan.

    C# csharp com help question

  • Interop - Marshaling nested structs
    N Nathan Tran

    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 dwH

    .NET (Core and Framework) csharp com help question

  • Interop - Marshaling nested structs
    N Nathan Tran

    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 dwH

    C# csharp com help question

  • Enter key pressed in a VS.NET addin control
    N Nathan Tran

    Hi again, A question for people who've worked on vs.net addins: How do I get a handle on the toolbox window that holds the addin control so that I can gracefully destroy it? At the moment, I have to compile/exit vs.net/restart in order to load a new instance of the addin. Also one other peculiarity. I've noticed that I have to load my addin project in order for the actual addin to load (release build). I've have to look into this a little further. Any clue? Nathan.

    C# question csharp visual-studio help tutorial

  • Enter key pressed in a VS.NET addin control
    N Nathan Tran

    Hi, I'm developing an irc client add-in for vs.net. On the control hosted by a toolbox window I have various textbox controls. I'm trying to acknowledge when the ENTER key is pressed within a textbox. I've done this before on a winform so I do know how to use the KeyDown, KeyUp, KeyPress events to check for the e.KeyCode == Keys.Return or e.KeyChar == '\r' or e.KeyChar == (char)13. None of these methods work. I have reason to believe that the problem arises from the fact that the textbox is hosted in a CUSTOM control and not a form. From tests I've done, I found out that the textbox does not process the following keys: ENTER, NUMPAD ENTER, CONTROL, ALT, etc...the list goes on. How do I get the textbox to process ENTER key presses? Nathan.

    C# question csharp visual-studio help tutorial

  • Remoting: Inter object communication.
    N Nathan Tran

    Hi John, For communicating across a firewall I believe you have to set the HttpChannel on the client side to port 80 or a port that is not blocked. I haven't tried this myself since I'm still coding the message/user handling routines for my chat server. If you have time on your hands could you verify this? Thanks. Nathan.

    C# question sysadmin help lounge

  • using the KeyEventArgs.Handled prop
    N Nathan Tran

    Hi, This may help. For the KeyPress event of the control: private void tbMsg_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if( e.KeyChar == ( char )13 ) // (char)13 is the return key. { // Tell the system that the keypress has been handled. e.Handled = true; // Do something. Here I'm simulating a button press. button1_Click( this, e ); } } Nathan.

    C# question

  • That AppUpdater thing from GotDotNet
    N Nathan Tran

    Hi, If you log into irc on Efnet and go to #ms.net you can ask either ^CareBear or Wilco about this since they've dissected this example and even made their own variant. Nathan.

    C# announcement com sysadmin collaboration xml

  • Remoting: Inter object communication.
    N Nathan Tran

    John, AFAIK .NET remoting supports serialization of client objects across channel by reference. I am banking on this reference to the client object to maintain a "connection" between server-client. To send a message back to the client I can simply call clientObjectRef.MsgServicingDelegate( Msg ); Indeed this solution will pose a scalability issue since, in affect, the client maintains an open channel with the server. Is this a wise solution? To what extent is the overhead required to maintain an open httpChannel? More importantly, how does the underlying framework acheives this feat? Nathan.

    C# question sysadmin help lounge

  • Remoting: Inter object communication.
    N Nathan Tran

    Hi, I'm trying to code a chat server that supports tcp/udp connections as well as connections through remoting if the client is behind a firewall. How can I implement the server so that it will support both types of clients? The problem is that remoting requires the server object to be activated by the client but I need the server to be running all the time to support clients that are not using remoting to connect to it. So the question is, how does an pre-existing object ( instantiated before the activation of the remoting object ) communicate with an object that is activated remotely by a client? The existing object and the activated object are in the same application domain ( I presume ). This problem has been bugging me for days. I searched the net and there are a whole bunch of remoting tutorials, but none touches on this particular subject. Hopefully, some one here has a clue. Nathan.

    C# question sysadmin help lounge
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups