Special cases

There are cases where custom processing is required, such as sending a message with a pointer to an array of integers. For situations like this, the Marshal class provides methods to copy data directly to the unmanaged buffer, at specified offsets (so you can construct an array of a custom data type after allocating a buffer). The following example shows how to send a message where the LParam is a pointer to an array of Integer:

function SendArrayMessage(Handle: HWND; Msg: UINT; WParam: WPARAM;

LParam: TIntegerDynArray): LRESULT; var

Buffer: IntPtr; begin

Buffer := Marshal.AllocHGlobal(Length(LParam) * SizeOf(Integer)); try

  1. Copy(LParam, 0, Buffer, Length(LParam)); Result := SendMessage(Handle, Msg, WParam, Buffer); finally
  2. FreeHGlobal(Buffer);
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment