type
TMyRecord = record
IntBuffer: array[0..31] of Integer;
CharBuffer: array[0..127] of Char;
lpszInput: LPTSTR;
lpszOutput: LPTSTR;
end;
Would be declared as follows in Delphi 2005: type
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
TMyRecord = record
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
IntBuffer: array[0..31] of Integer;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
CharBuffer: string;
[MarshalAs(UnmanagedType.LPTStr)]
lpszInput: string;
lpszOutput: IntPtr;
end;
The above declarations assume that the strings contain platform dependant TChar’s (as commonly used by the Win32 API). It is important to note that in order to receive text in lpszOutput, the Marshal. procedure SetRect(Handle: HWND; const Rect: TRect);
var
Buffer: IntPtr;
begin
Buffer := Marshal.AllocHGlobal(Marshal.SizeOf(TypeOf(TRect)));
try
Marshal.StructureToPtr(TObject(Rect), Buffer, False);
SendMessage(Handle, EM_SETRECT, 0, Buffer);
finally
Marshal.DestroyStructure(Buffer, TypeOf(TRect));
end;
end;
procedure GetRect(Handle: HWND; var Rect: TRect);
var
Buffer: IntPtr;
begin
Buffer := Marshal.AllocHGlobal(Marshal.SizeOf(TypeOf(TRect)));
try
SendMessage(Handle, EM_GETRECT, 0, Buffer);
Rect := TRect(Marshal.PtrToStructure(Buffer, TypeOf(TRect)));
finally
Marshal.DestroyStructure(Buffer, TypeOf(TRect));
end;
end;
It is important to call
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




