Board index » delphi » I need to draw onto all the controls of a form

I need to draw onto all the controls of a form

I'm tryng to draw on a form that contain some panels :
      Form->Canvas->MoveTo(strX, strY);
      Form->Canvas->LineTo(actX, actY);

In this way the lines drawed are below the panels.

How i can draw onto all the controls of my form ?
How i can save the region under the line to restore the screen ?

Thanks in advance.

 

Re:I need to draw onto all the controls of a form


Hi Paolo!

I don't know what exactly you want to do but one soultion would be to
make a screenshot of the window (examples can be found everywhere), open
a new window with BorderStyle bsnone, put the screenshot on it and draw
whatever you like. Doing this you save / restore the region below. Hope
that helps!

Jens

Quote
Paolo wrote:
> I'm tryng to draw on a form that contain some panels :
>       Form->Canvas->MoveTo(strX, strY);
>       Form->Canvas->LineTo(actX, actY);

> In this way the lines drawed are below the panels.

> How i can draw onto all the controls of my form ?
> How i can save the region under the line to restore the screen ?

> Thanks in advance.

Re:I need to draw onto all the controls of a form


Just print on the DesktopWindow

Re:I need to draw onto all the controls of a form


I snagged this code from these newsgroups.  It supposedly gave an
example of being able to draw lines over EVERYTHING on your form.
I have not tried it, but it should give you a start.

  TForm1 = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormShow(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
    MD: Boolean;
    DP: TPoint;
  public
    { Public declarations }
    Procedure BoundMouse(const isLimit: Boolean);
    Procedure OverDraw(const isOver: Boolean);
  end;

......
procedure TForm1.FormShow(Sender: TObject);
begin
  MD:= False;
end;

Procedure TForm1.BoundMouse(const isLimit: Boolean);
Var
  MRect: TRect;
Begin
  If isLimit then
  Begin
    MRect.TopLeft:= ClientToScreen(Point(0,0));
    MRect.BottomRight:= ClientToScreen(Point(ClientRect.Right,
ClientRect.Bottom));
    ClipCursor(@MRect);
  End Else
    ClipCursor(nil);
End;

Procedure TForm1.OverDraw(const isOver: Boolean);
Var
  Style: Longint;
Begin
  Style:= GetWindowLong(Handle, GWl_Style);
  If isOver then
    Style:= Style and (not WS_ClipChildren)
  Else
    Style:= Style or WS_ClipChildren;

  SetWindowLong(Handle, GWl_Style, Style);
End;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  DP:= Point(X, Y);

  MD:= True;
  BoundMouse(MD);
  OverDraw(MD);
  Canvas.Pen.Width:= 2;
{2}  Canvas.Pen.Mode:= pmNotXor;
  Canvas.Pen.Color:= RGB(Random(256), Random(256), Random(256));{2}

{1  Canvas.Pen.Mode:= pmXor;//pmNotXor;
  Canvas.Pen.Color:= RGB(Random(256), Random(256), Random(256));
  Canvas.Brush.Style:= bsClear;{1}

  Canvas.Rectangle(X-50, Y-50, X+50, Y+50);
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  If MD then
  Begin
    Canvas.Rectangle(DP.X-50, DP.Y-50, DP.X+50, DP.Y+50);
    DP:= Point(X, Y);
    Canvas.Rectangle(DP.X-50, DP.Y-50, DP.X+50, DP.Y+50);
  End;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Canvas.Rectangle(DP.X-50, DP.Y-50, DP.X+50, DP.Y+50);
  MD:= False;
  BoundMouse(MD);
  OverDraw(MD);
end;

Quote
Paolo wrote:
> I'm tryng to draw on a form that contain some panels :
>       Form->Canvas->MoveTo(strX, strY);
>       Form->Canvas->LineTo(actX, actY);

> In this way the lines drawed are below the panels.

> How i can draw onto all the controls of my form ?
> How i can save the region under the line to restore the screen ?

> Thanks in advance.

Other Threads