SetRgnRect example for Delphi
procedure TForm1.Button1Click(Sender: TObject);
var
{Declare local variables.}
OffsetX, OffsetY: integer;
SavedRegion: HRGN;
begin
{Initialize the variables that we will manipulate to simulate mouse coordinates.}
OffsetX := Lead1.BitmapWidth div 8;
OffsetY := Lead1.BitmapHeight div 6;
{Create a region.}
Lead1.SetRgnRect(OffsetX, OffsetY, OffsetX, OffsetY, L_RGN_SET);
{Save a copy of the region.}
SavedRegion := Lead1.GetRgnHandle;
{Add the saved region to the bitmap, offsetting it so that we can see it.}
Lead1.SetRgnHandle(SavedRegion, OffsetX, OffsetY, L_RGN_OR);
{Delete the saved region.}
Lead1.DeleteRgnHandle(SavedRegion);
{Fill the bitmap region with blue.}
Lead1.Fill(RGB(0, 0, 255));
{Free the bitmap region.}
Lead1.FreeRgn;
{Repaint the image so that we can see how the image was updated. }
Lead1.ForceRepaint;
end;