Create a hole in application running

Posted in Forms

Use GetWindowRect, CombineRgn WinAPI functions, like this example:

var
  Wnd: HWnd;
  Region1, Region2: HRgn;
  Rect: TRect;
begin
  Wnd:=Application.MainForm.Handle;
  GetWindowRect(Wnd,Rect);
  Region1:=CreateRectRgn(0,0,Rect.Right-Rect.Left,Rect.Bottom-Rect.Top);
  Region2:=CreateEllipticRgn(10,30,150,120);
  CombineRgn(Region1,Region1,Region2,RGN_DIFF);
  SetWindowRgn(Wnd,Region1,True);
end;