Click here to Skip to main content
15,896,207 members
Home / Discussions / C#
   

C#

 
GeneralRe: thread confusion Pin
valikac17-May-04 18:33
valikac17-May-04 18:33 
GeneralRe: thread confusion Pin
macromark18-May-04 10:05
macromark18-May-04 10:05 
GeneralPropertyGrid ----Third Party tool Pin
Jay Shankar17-May-04 18:19
Jay Shankar17-May-04 18:19 
GeneralRe: PropertyGrid ----Third Party tool Pin
Heath Stewart18-May-04 3:49
protectorHeath Stewart18-May-04 3:49 
GeneralRe: PropertyGrid ----Third Party tool Pin
leppie18-May-04 7:16
leppie18-May-04 7:16 
GeneralRe: PropertyGrid ----Third Party tool Pin
Heath Stewart18-May-04 7:21
protectorHeath Stewart18-May-04 7:21 
Questionhow to use *msg in C# ? Pin
fu017-May-04 15:31
fu017-May-04 15:31 
AnswerRe: how to use *msg in C# ? Pin
Heath Stewart18-May-04 3:54
protectorHeath Stewart18-May-04 3:54 
MSG is a simple struct:
[StructLayout(LayoutLind.Sequential)]
public struct MSG
{
  public IntPtr hwnd;
  [MarshalAs(UnmanagedType.SysUInt)] public IntPtr message;
  public IntPtr wParam;
  public IntPtr lParam;
  [MarshalAs(UnmanagedType.U4)] public int time;
  public System.Drawing.Point pt;
}
The second field is an IntPtr because the unmanaged type UINT is a processor-dependent bit width: 32 bits on a 32-bit CPU and 64 bits on a 64-bit CPU. To pass a value, just use new IntPtr(someNum);

If you need a pointer to this struct (MSG*), you can either use the Marshal.StructureToPtr to marshal it to an IntPtr or - even easier - declare the method that accepts the MSG* as ref MSG msg. Here's an example:
[DllImport("user32.dll")]
private static extern bool SomeExampleFunc(ref MSG msg);
This automatically marshals the MSG struct (that you simply instantiate and fill the fields) as a MSG*.

 

Microsoft MVP, Visual C#
My Articles
GeneralDataTable - DataGrid Pin
moonboy17-May-04 14:33
moonboy17-May-04 14:33 
GeneralRe: DataTable - DataGrid Pin
Jay Shankar17-May-04 16:07
Jay Shankar17-May-04 16:07 
GeneralRe: DataTable - DataGrid Pin
Moon Boy17-May-04 18:20
Moon Boy17-May-04 18:20 
GeneralRe: DataTable - DataGrid Pin
Jay Shankar17-May-04 20:34
Jay Shankar17-May-04 20:34 
GeneralRe: DataTable - DataGrid Pin
Heath Stewart18-May-04 3:55
protectorHeath Stewart18-May-04 3:55 
GeneralA strange question I think Pin
Christer Claesson17-May-04 12:16
Christer Claesson17-May-04 12:16 
GeneralRe: A strange question I think Pin
Colin Angus Mackay17-May-04 12:57
Colin Angus Mackay17-May-04 12:57 
GeneralRe: A strange question I think Pin
Christer Claesson17-May-04 13:07
Christer Claesson17-May-04 13:07 
GeneralRe: A strange question I think Pin
Colin Angus Mackay18-May-04 0:42
Colin Angus Mackay18-May-04 0:42 
GeneralMailto via code with attachment option Pin
myNameIsRon17-May-04 10:26
myNameIsRon17-May-04 10:26 
GeneralRe: Mailto via code with attachment option Pin
Heath Stewart17-May-04 10:52
protectorHeath Stewart17-May-04 10:52 
Generalregd Datagrid Pin
karteek17-May-04 8:39
karteek17-May-04 8:39 
GeneralRe: regd Datagrid Pin
Heath Stewart17-May-04 8:53
protectorHeath Stewart17-May-04 8:53 
GeneralRe: regd Datagrid Pin
Jay Shankar17-May-04 23:11
Jay Shankar17-May-04 23:11 
GeneralRe: regd Datagrid Pin
karteek17-May-04 23:19
karteek17-May-04 23:19 
GeneralRe: regd Datagrid Pin
Jay Shankar17-May-04 23:38
Jay Shankar17-May-04 23:38 
Generalmanaging the edit of a dataGrid Pin
HappyPaws17-May-04 8:36
HappyPaws17-May-04 8:36 

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.