I have read some questions about this in the last week or so, on stackoverflow.
My requirement is more or less the same.
I need to put a semi-transparent lay
Create a new VCL project. Add a few sample buttons and other controls to the main form. Create a new form, set AlphaBlend to true and AlphaBlendValue to 128. Perhaps Color = clSkyBlue will suffice? Then add the following procedure to your main form:
procedure TForm1.UpdateShadow;
var
pnt: TPoint;
rgn, rgnCtrl: HRGN;
i: Integer;
begin
if not Assigned(Form2) then Exit;
Form2.Show;
pnt := ClientToScreen(Point(0, 0));
Form2.SetBounds(pnt.X, pnt.Y, ClientWidth, ClientHeight);
rgn := CreateRectRgn(0, 0, Form2.Width, Form2.Height);
for i := 0 to ControlCount - 1 do
if Controls[i].Tag = 1 then
begin
if not (Controls[i] is TWinControl) then Continue;
with Controls[i] do
rgnCtrl := CreateRectRgn(Left, Top, Left+Width, Top+Height);
CombineRgn(rgn, rgn, rgnCtrl, RGN_DIFF);
DeleteObject(rgnCtrl);
end;
SetWindowRgn(Form2.Handle, rgn, true);
DeleteObject(rgn);
end;
and call this on resize,
procedure TForm1.FormResize(Sender: TObject);
begin
UpdateShadow;
end;
and form move:
procedure TForm1.WMMove(var Message: TWMMove);
begin
inherited;
UpdateShadow;
end;
Finally, set the Tag to 1 on the controls (on your main form) that are to be accessible.
(source: rejbrand.se)
Hint: You might also wish to set the Cursor of the 'shadow form' to crNo.