Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[14046] Re:스코롤박스안에 있는 여러개의 체크박스를 드레그로 선택하려면 어떻게 하나요?
civilian [civilian] 1872 읽음    2012-01-11 14:49
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    ScrollBox1: TScrollBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    procedure ScrollBox1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ScrollBox1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
    FDown: Boolean;
    FStartPos: TPoint;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ScrollBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Button = mbLeft) and (Shift = [ssLeft]) then
  begin
    FDown := True;
    FStartPos := Point(X, Y);
  end;
end;

procedure TForm1.ScrollBox1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  ControlPos: TPoint;
  SelectRect: TRect;
  i: Integer;
  CheckBox: TCheckBox;
begin
  if FDown then
  begin
    FDown := False;

    SelectRect := Rect(FStartPos.X, FStartPos.Y, X, Y);

    for i := 0 to ScrollBox1.ControlCount-1 do
    begin
      if ScrollBox1.Controls[i] is TCheckBox then
      begin
        CheckBox := ScrollBox1.Controls[i] as TCheckBox;
        ControlPos := Point(CheckBox.Left, CheckBox.Top);

        if PtInRect(SelectRect, ControlPos) then
          CheckBox.Checked := not CheckBox.Checked;
      end;
    end;
  end;
end;

end.



하두고 님이 쓰신 글 :
: 폼위에 스코롤박스가 있고
: 스코롤박스 안에 여러개의 체크박스가 있습니다.
:
: 체크박스를 하나씩 클릭해서 선택하려니 사용자가 귀찮을 것 같습니다.
: 그렇다고 리스트박스로 구현하기는 좀 곤란한 문제가 있구요.
:
: 스코롤박스안에 있는 여러개의 체크박스를 마우스로 드레그하여 한 번에 선택하게 하고 싶은데
: 어떻게 해야 할지 모르겠습니다.
:
: 도움 부탁드립니다.

+ -

관련 글 리스트
14042 스코롤박스안에 있는 여러개의 체크박스를 드레그로 선택하려면 어떻게 하나요? 하두고 1867 2012/01/10
14046     Re:스코롤박스안에 있는 여러개의 체크박스를 드레그로 선택하려면 어떻게 하나요? civilian 1872 2012/01/11
14049         Re:Re:스코롤박스안에 있는 여러개의 체크박스를 드레그로 선택하려면 어떻게 하나요? 하두고 1807 2012/01/11
14050             Re:Re:Re:스코롤박스안에 있는 여러개의 체크박스를 드레그로 선택하려면 어떻게 하나요? 장성호 1760 2012/01/11
14051                 Re:Re:Re:Re:스코롤박스안에 있는 여러개의 체크박스를 드레그로 선택하려면 어떻게 하나요? 하두고 1698 2012/01/11
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.