This project doesn't do anything very interesting. What it does do is emphasize that many of the controls available to the application designer are windowed and that any of the windowed controls can have a window region set. There is no need to restrict yourself to mere application windows. This particular program changes the region of a TPanel when the form is resized. There is a TImage behind panel and another one in it. The panel's window region is shown by the way it clips the image inside it...

Anyway, here's the important part of the code...

procedure TForm1.FormResize(Sender: TObject);
  var
    ClientRect : TRect;
    LeftRgn : HRGN;
  begin
  ClientRect := GetClientRect;
  LeftRgn  := CreateEllipticRgn(ClientRect.left,
                                ClientRect.Top,
                                ClientRect.Right,
                                ClientRect.Bottom);
  SetWindowRgn(panFrontImage.handle,LeftRgn,false);
  end;

Frankly, this program is a bit more pretty and a bit less obvious than it could be. If you download the project and have a look at the form, both images and the panel all are aligned to client. This makes the form a little hard to figure out. If you run into trouble, just go through the control list and select each of them and set alignment to none. Then you can move or resize them a bit to see how they interact. If anybody is actually confused enough to complain, maybe I'll do something that is easier to understand.

Download Project

Peter M. Gruhn