Transparent Forms

    Right on both counts. Actually, I found that putting the code in the
OnPaint event takes care of both situations. One might question the
usefulness of a hole with a title bar, borders (and, eventually a menu) but
what mister Valdar wishes to do as a consenting adult is none of my
concerns.
    However, if the glitz of a transparent form might add to the sales pitch
of a poor freelance programmer such as myself (remember, we're talking
Microsoft clients, here), it would be much more helpful if it could show a
few controls. The standard OnPaint event should therefore look somewhat like
this:

procedure TForm1.FormPaint(Sender: TObject);
var
 FormRgn, ClientRgn, ResultRgn: HRGN;
  i, RightShift, DownShift: Byte;
begin
 FormRgn:=CreateRectRgn(0, 0, Pred(Width), Pred(Height));
  ResultRgn:=CreateRectRgn(0, 0, 0, 0);
  with ClientOrigin do
  begin
    RightShift:=X-Left;
    DownShift:=Y-Top;
   ClientRgn:=CreateRectRgn(RightShift, DownShift, RightShift+ClientWidth,
DownShift+ClientHeight);
  end;
  CombineRgn(ResultRgn, FormRgn, ClientRgn, RGN_XOR);
  for i:=0 to Pred(ControlCount) do
   if Controls[i].Visible then
    begin
     CombineRgn(FormRgn, ResultRgn, 0, RGN_COPY);
     with Controls[i] do
      ClientRgn:=CreateRectRgn(RightShift+Left, DownShift+Top,
RightShift+Left+Width, DownShift+Top+Height);
      CombineRgn(ResultRgn, FormRgn, ClientRgn, RGN_OR);
    end;
  SetWindowRgn(Handle, ResultRgn, True);
end;

    Now, this is the setup for major headaches since the OnPaint event isnt
triggered as frequently as you'd expect. Until now, I found it necessary to
call it on both scrolling events, as well as on changes to a TImage,
especially if its AutoSize property is set to True. I havent tested it yet
but I suspect one would have to check events such as control creation and
destruction or even just showing and hiding them unless you find poetry in
leaving a fossilized impression of them. Of course, if one could detect a
message that would cover all these events without being overkill, it would
make it much more simple.
        Gilbert

-----Original Message-----

:Something may need to be done in the OnResize event too right ? And this
:Form will actually have a "hole" in it except for the title bar and the
:borders. But how else would you have it transparent ! Very good example
:though.

    Sorry for looking like I'm upstaking on Ahto's message; I mistakenly
deleted the original question. Here's the specific way to use SetWindowRgn
in this case:

procedure TForm1.FormCreate(Sender: TObject);
var
 FormRgn, ClientRgn, ResultRgn: HRGN;
begin
 FormRgn:=CreateRectRgn(0, 0, Width, Height);
  ResultRgn:=CreateRectRgn(0, 0, 0, 0);
  with ClientOrigin do
   ClientRgn:=CreateRectRgn(X-Left, Y-Top, X-Left+ClientWidth,
Y-Top+ClientHeight);
  CombineRgn(ResultRgn, FormRgn, ClientRgn, RGN_DIFF);
  SetWindowRgn(Handle, ResultRgn, True);
end;

-----Original Message-----
:
:>I have a form with a transparent background.  This works fine, but when
:>I move the form the back ground is the same.  I tried to refresh, update
:>and paint the background but with no luck.
:>
:>Does anyone know how to refresh the transparent image on a form.
:>
:>Code used to make form transparent
:>
:>procedure TForm1.FormCreate(Sender: TObject);
:>begin
:>  Form1.Brush.Style := bsClear;
:>  Form1.BorderStyle := bsNone
:>end;
--------
Way dosn't this procedure work as intended under Windows 98.
I want the window to look like this.
   _________
 _!         !_
!             !
!             !
!             !
!_           _!
  !_________!

procedure TForm1.FormCreate(Sender: TObject);
var
  FormRgn1,  FormRgn2,  FormRgn3,  FormRgn : HRgn;
begin
  GetWindowRgn(form1.Handle,FormRgn);
  DeleteObject(FormRgn);
  FormRgn1 := CreateRectRgn(40,0,600,480);
  FormRgn2 := CreateRectRgn(0,40,640,440);
  CombineRgn( FormRgn, FormRgn1, FormRgn2, Rgn_And);
  SetWindowRgn(Handle,FormRgn,True);
end;