victorlus 0 Posted February 15, 2021 (edited) 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 https://prnt.sc/zlgok0 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 February 15, 2021 by victorlus Share this post Link to post
victorlus 0 Posted February 15, 2021 (edited) How do I want to do more? Doesn't it work? Does anyone have the solution? - Edited February 15, 2021 by victorlus Share this post Link to post
victorlus 0 Posted February 15, 2021 How do I want to do more? Doesn't it work? Does anyone have the solution? -> https://prnt.sc/zlp562 Share this post Link to post
David Heffernan 2345 Posted February 15, 2021 Please don't spam the site with duplicate posts. When you do post, please don't use ultra large text. 1 Share this post Link to post
victorlus 0 Posted February 15, 2021 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
Mark- 29 Posted February 15, 2021 49 minutes ago, David Heffernan said: When you do post, please don't use ultra large text. SMH Share this post Link to post
FPiette 382 Posted February 15, 2021 And do not post the same question here and on StackOverflow. The same pleoples are answering anyway. Share this post Link to post
victorlus 0 Posted February 15, 2021 1 minute ago, FPiette said: E não poste a mesma pergunta aqui e no StackOverflow . As mesmas pessoas estão respondendo de qualquer maneira. Do you know how to solve? Share this post Link to post
FPiette 382 Posted February 15, 2021 You should better explain what is the problem. Share this post Link to post
victorlus 0 Posted February 15, 2021 (edited) 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 February 15, 2021 by victorlus Share this post Link to post
Guest Posted February 16, 2021 here is it your answer (if I understand of course): hug Share this post Link to post