代码如下(当鼠标划过窗体时,会擦掉窗体固定区域的背景):
procedure FormOnMouseMove(...);
const
EraseWidth = 8;
var
rectErase: TRect;
hrgnErase: HRGN;
begin
IntersectRect(rectErase, Rect(80, 80, 400, 200), Rect(X - EraseWidth, Y - EraseWidth, X + EraseWidth, Y + EraseWidth));
hrgnErase := CreateRectRgnIndirect(rectErase);
//此处,不用事先将 Region 用 SelectObject 选入设备环境
FillRgn(Canvas.Handle, hrgnErase, GetStockObject(WHITE_BRUSH));
DeleteObject(hrgnErase);
end;