Jump to content
victorlus

(Hole) align hole inside the panel form 1

Recommended Posts

 

I'm trying to make a hole in the form 2 align the hole of the form 2 inside the form 1 inside the panel someone can help me in this solution.

 

Here is a printout of the error can someone help me with this 
Quote

 

How do I want to do more? Doesn't it work? Does anyone have the solution? -> Image https://prnt.sc/zlp562 

 

 

Quote

type
  TForm2 = class(TForm)
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
    var
    x1, y1, x2, y2: Integer;
    ptnd: Boolean;
    AnchorX, AnchorY, CurX, CurY: Integer;
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

const
  vH: Byte = 10;
  vV: Byte = 30;


procedure TForm2.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  x1 := x + vH;
  y1 := y + vV;
  ptnd := True;
  AnchorX := X;
  CurX := X;
  AnchorY := Y;
  CurY := Y;
end;

procedure TForm2.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Caption := 'x1: ' + IntToStr(x1) + '; y1 ' + IntToStr(y1) + '; x2 ' + IntToStr(x2) + '; y2 ' + IntToStr(y2) + ';';
  if ptnd then
  begin
    Canvas.Pen.Mode := pmNot;
    Canvas.Pen.Width := 2;
    Canvas.Brush.Style := bsClear;
    Canvas.Rectangle(AnchorX, AnchorY, CurX, CurY);
    CurX := X;
    CurY := Y;
    Canvas.Rectangle(AnchorX, AnchorY, CurX, CurY);
  end;
end;

procedure TForm2.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  region1, region2, rg2, rg1: hrgn;
  RECT : TRECT;
begin
  x2 := x + vH;
  y2 := y + vV;
  //if Shift = [ssCtrl] then
  begin
    region1 := CreateRectRgn(0, 0, Self.Width, Self.Height);
    region2 := CreateRectRgn(x1, y1, x2, y2);
    CombineRgn(region1, region1, region2, RGN_DIFF);
    SetWindowRgn(Handle, region1, True);


    getwindowrect(form1.Panel1.Handle,rect);


    Form1.Left := Form2.Left - Form1.Left;
    Form1.Top  := Form2.Top  - Form1.Top;

    form1.Show;
    region1 := CreateRectRgn(0, 0, form1.Width, form1.Height);
    region2 := CreateRectRgn(x1, y1, x2, y2);
    CombineRgn(region1, region1, region2, RGN_DIFF);
    SetWindowRgn(form1.Handle, region1, True);

  end;
  if ptnd then
  begin
    ptnd := False;
    Canvas.Pen.Mode := pmNot;
    Canvas.Brush.Style := bsClear;
    Canvas.Rectangle(AnchorX, AnchorY, CurX, CurY);
  end;

end;

 

 

Edited by victorlus

Share this post


Link to post

 

How do I want to do more? Doesn't it work? Does anyone have the solution? - 

 

 

Edited by victorlus

Share this post


Link to post
Just now, David Heffernan said:

Por favor, não envie spam para o site com postagens duplicadas. Ao postar, não use texto muito grande.

Sorry friend it was not my intention to do this

Share this post


Link to post
49 minutes ago, David Heffernan said:

When you do post, please don't use ultra large text.

SMH

Share this post


Link to post
12 minutes ago, FPiette said:

Você deve explicar melhor qual é o problema.

Yes what I wanted to do was the hole in the form2 and the form1 to align with the hole of the form2 inside a panel
Edited by victorlus

Share this post


Link to post
Guest

here is it your answer (if I understand of course): :classic_cheerleader:

 

 

hug

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×