Jump to content

victorlus

Members
  • Content Count

    12
  • Joined

  • Last visited

Posts posted by victorlus


  1. 19 minutos atrás, emailx45 disse:

    OK! Mas, ao usar "CreateRectRgn" e "CombineRgn", VOCÊ PRECISA excluir os objetos antigos "regiões" - consulte a Documentação da Microsoft! 

    Você não pode deixar como "velhas regiões" na memória! Apenas a nova região (o "combinado")

     

    Meu código para você necessariamente que é o mesmo!

    • apenas mude a escolha de FORMA = se você precisar de um "quadrado", mude para "Forma = stSquare"

     

    image.thumb.png.14323f97d133263cbe8a11d42948ee51.png

    abraço

    
     

     

    I'm having a little trouble using 

  2. Manee.thumb.png.7fb0742605509de4b9bc26870b0c2a42.png

    Form2

    https://imgur.com/a/IfsTxeu

    Form1: 

    https://imgur.com/1mzTI66

    I'm trying to align, form 2, together with form 1, with the same hole in the same size, without moving the shape of the form, only height and width

    Obs : 

    If I don't use the mouse event it works normally

     

     

    Code: 

    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;
      protected                      
      public
        { Public declarations }
      end;
    
    var
      Form2: TForm2;
      X1frmFormMainShapeLeft: Integer;
      Y1frmFormMainShapeTop: Integer;
    
    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 := 8;
        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
      lMyOffsetTop : integer;
      lMyOffsetLeft: integer;
    begin
      x2 := x + vH;
      y2 := y + vV;
      lMyOffsetTop := 11; // você precisa calcular os valores verticais da margem (área não cliente)
      lMyOffsetLeft := 11; // calcula os valores horizontais da margem (área não cliente)
      begin
    
    
    
          Shape1.Top := Y;
          Shape1.Left := X;
          Shape1.Width := x1 - x2;
          Shape1.Height := y1 - y2;
    
    
          Form1.Shape1.Top := 40;
          Form1.Shape1.Left := 40;
          Form1.Shape1.Width :=  x1 - x2;
          Form1.Shape1.Height :=  y1 - y2;
    
    
          Y1frmFormMainShapeTop  := ClientToScreen(Point(0, 0)).Y + Shape1.Top - (Self.Height - Self.ClientHeight) + lMyOffsetTop;
          X1frmFormMainShapeLeft := ClientToScreen(Point(0, 0)).X + Shape1.Left - (Self.Width - Self.ClientWidth) + lMyOffsetLeft;
    
    
     	  Form1.Left := X1frmFormMainShapeLeft - form1.Shape1.Left;
       	  Form1.Top  := Y1frmFormMainShapeTop - form1.Shape1.Top;
    
         Form1.Show;
     if ptnd then
     begin
      end;
        ptnd := False;
        Canvas.Pen.Mode := pmNot;
        Canvas.Brush.Style := bsClear;
        Canvas.Rectangle(AnchorX, AnchorY, CurX, CurY);
      end;
    end;

     


  3.  

    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;

     

     


  4. Hello everyone
    Well, I have a question, I hope you can help me,
    Next, I have 2 forms
    Form2, Form1
    Form2 cuts the screen well
    What I wanted to do was when you cut out form 2, open form 1,
    cut it and move it over the cut of shape 2
    if possible, cut form 2 is inside panel 1 of form 

    Image -> Error Matched form1

     

    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.Top := Round((x1 + y1)/2);
        Form1.Left := Round((x2 + y2)/2);
        form1.Show;
    
        region1 := CreateRectRgn(0, 0, self.Width, self.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;

     

×