귀하는 손님 이십니다
로그인
회원가입
  
  델마당 공식 은행계좌
  하나은행 227-910235-83607
  예금주 이상국(운영진)
프로젝트 게시판
투표게시판
델마당소개
기초부터 활용까지! 델파이 교육 - 데브기어
媛뺤쥖, 똻, 젙蹂 媛뺤쥖, 똻, 젙蹂 입니다.
글내용 - 媛뺤쥖, 똻, 젙蹂
 留덉슦뒪濡 뱶옒洹명빐꽌 뙋꽟쐞뿉 궗媛곹삎 쁺뿭 留뚮뱾뼱 뿬윭 而댄룷꼳듃(뙋꽟) 꽑깮븯湲
쁺쁺
(넚醫낆쁺)
2019-12-08 삤썑 10:42:04
카테고리: 똻
1143회 조회



등록된 파일이 없습니다.

뼱由곗솗옄 떂씠 삱由곌쾬쓣 議곌툑 닔젙븯뒿땲떎.

  private
    { Private declarations }

  public
    { Public declarations }

    procedure MouseControl(x,y:Integer);
  end;

var
  Form1: TForm1;

  Mouse_Down_Bool : Boolean;

  startX, startY : integer;

  fDragging : Boolean;
  fRect : TRect;


implementation

 

{$R *.DFM}

procedure TForm1.Panel_BackMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  i:integer;
begin
  // PaintBox1.Enabled := False 삉뒗 PaintBox1.Visible := False 濡 빐빞留 洹몃젮吏.

  if  shift = [ssctrl,ssleft] then
  begin

  // 泥 뱶옒洹(Ctrl+left)떆옉븯湲곗쟾뿉 珥덇린솕

    fDragging := true; //쟾뿉 뱶옒洹명뵆옒洹몃닔(Private) 젙쓽븿.
    fRect.Left := 0;
    fRect.Right := 0;
    fRect.Top := 0;
    fRect.Bottom := 0;

    PaintBox1.Canvas.DrawFocusRect(fRect);

  // 떆옉쐞移섍린뼲븯뒗 蹂닔(Private)
    StartX := X;
    StartY := Y;
  end;

end;

procedure TForm1.Panel_BackMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
begin
  if fDragging then
  begin
    With PaintBox1 do // 럹씤듃諛뺤뒪뿉 궗媛곹삎 쁺뿭쓣 洹몃┝
    begin
     Canvas.DrawFocusRect(fRect); // 씠쟾쓽 궗媛곹삎쓣 吏슦怨

     fRect.Left:= Min(StartX,x);
     fRect.Right:= Max(StartX,x);
     fRect.Top:= Min(StartY,y);
     fRect.Bottom:= Max(StartY,y);

     Canvas.DrawFocusRect(fRect);  // 떎떆 쁺뿭쑝濡 궗媛곹삎쓣 洹몃━怨
    end;
 end;

end;

procedure TForm1.Panel_BackMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  i, WidthNum, HeightNum : integer;
  PnlSender : TPanel absolute Sender;
  TmpPanel:TPanel;

begin
  if fDragging then
  begin
    for i := 0  to PnlSender.ControlCount - 1 do
    begin

    // 而⑦듃濡ㅼ씠 TPanel씤媛?
     if (PnlSender.controls[i] is TPanel) then
     begin
      // 媛곴컖쓽 Panel쓣 씫뼱꽌
      TmpPanel:= TPanel(PnlSender.controls[i]);

      WidthNum := Max(abs(TmpPanel.left + TmpPanel.width - fRect.Left),
                    abs(TmpPanel.left - fRect.Right));
     // 쁺뿭궗媛곹삎쓽 媛濡쒕怨 뙣꼸쓽 媛濡쒕쓽 媛옣癒쇨굅由щ 援ы븳떎.

      HeightNum := Max(abs(TmpPanel.Top + TmpPanel.Height-fRect.Top),
                     Abs(TmpPanel.Top - fRect.Bottom));
     // 쁺뿭궗媛곹삎쓽 꽭濡쒕怨 뙣꼸쓽 깉濡쒕쓽 媛옣癒쇨굅由щ 援ы븳떎.

     // 留뚯씪 씠젃寃 援ы븳 媛곴컖쓽 嫄곕━媛, 쁺뿭궗媛곹삎,뙣꼸쓽 媛濡쒗빀,꽭濡쒗빀蹂대떎 겕硫 寃뱀튇떎.( 븳吏곸꽑긽쓽 몢媛쒖쓽 꽑遺꾩씠 寃뱀튌議곌굔..)
      if (WidthNum <= ((fRect.Right - fRect.left) + (TmpPanel.width))) and
       (HeightNum <= ((fRect.Bottom - fRect.Top) + (TmpPanel.Height))) then
      begin
      { if TmpPanel.BorderWidth = 3 then
        TmpPanel.BorderWidth := 0
       else }
        TmpPanel.BorderWidth := 3;
      end;

     end;
    end; // for

    MouseControl(x,y);

    fDragging := false; // 뱶옒洹명뵆옒洹몃 false떆궎怨
    PaintBox1.Canvas.DrawFocusRect(fRect); // 쁺뿭 궗媛곹삎쓣 吏슦怨
    invalidate; // 떎떆 洹몃젮以.
    ClipCursor(nil); //留덉슦뒪 紐살吏곸씠뒗 쁺뿭쓣 빐泥

  end;
end;


// 뱶옒洹몃え뱶뿉꽌 留덉슦뒪媛 Panel_Back 諛뺤뒪궡 뿉留 吏곸씠寃 븯뒗 肄붾뱶
procedure TForm1.MouseControl(x,y:Integer);
var
  xbar, ybar : integer; // 뒪겕濡ㅻ컮쓽 꼻씠 蹂닔
  PanelRect : TRect;  // 뒪겕濡ㅻ컯뒪쓽 쁺뿭

begin
  xbar:=0;
  ybar:=0;

  PanelRect.TopLeft := Panel_Back.ClientToScreen(
                          Point(Panel_Back.left, Panel_Back.top + Panel_Back.top));

  PanelRect.Right := PanelRect.TopLeft.x + Panel_Back.Width;
  //뒪겕濡ㅻ컯뒪 븘옒履 踰붿쐞源뚯 紐살吏곴쾶 븿.
  PanelRect.bottom := PanelRect.TopLeft.y + Panel_Back.Height;

  InflateRect(PanelRect, 0,0); //API 븿닔
  ClipCursor(@PanelRect);  //而ㅼ꽌瑜 젙븳 踰붿쐞뿉 紐 吏곸씠寃 븿.
end;