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

C++빌더 Q&A
C++Builder Programming Q&A
[74328] Re:Panel 안에 있는 컴포넌트 들을 마우스 Drag 로 선택하는 방법[자답]
김시환 [godson2] 4120 읽음    2017-04-13 14:35
일단 아래처럼 구현은 했는데 뭔가 좀 찜찜합니다.
일단 Panel 컴포넌트로 하면 Panel 안의 글자는 잘 바뀌는데 색상 변하는 것은 첫번째 컴포넌트만 됩니다.
그래서 TShape 로 변경했더니 전체적으로 변하긴 하네요..

start  는 멤버 변수 입니다.

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TShape* pPanel[12] ;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
	pPanel[0] = Shape1 ;
	pPanel[1] = Shape2 ;
	pPanel[2] = Shape3;
	pPanel[3] = Shape4;
	pPanel[4] = Shape5;
	pPanel[5] = Shape6;
	pPanel[6] = Shape7;
	pPanel[7] = Shape8;
	pPanel[8] = Shape9;
	pPanel[9] = Shape10;
	pPanel[10] = Shape11;
	pPanel[11] = Shape12;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel13MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
		  int X, int Y)
{

		start.X = X ;
		start.Y = Y ;

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel13DragOver(TObject *Sender, TObject *Source, int X, int Y,
          TDragState State, bool &Accept)
{

		for(int loop=0 ; loop<12 ; loop++)
		{
			if(pPanel[loop]->Left > start.X && pPanel[loop]->Top > start.Y)
			{
				if(pPanel[loop]->Left < X && pPanel[loop]->Top < Y)
				{
				 pPanel[loop]->Brush->Color = clRed ;
				 }
				else 	pPanel[loop]->Brush->Color = clWhite ;
			}
			else 	pPanel[loop]->Brush->Color = clWhite ;

			Application->ProcessMessages() ;
		}

}




김시환 님이 쓰신 글 :
: Panel 컴포넌트 안에 매트릭스 형태로 조그마한 Panal 들을 넣어 놓았습니다.
:
: 마우스를 드래그하여  left, top 과 right, bottom 영역의 panel 들만 특정 색으로 변경하고 싶은데
: 생각처럼 되지를 않네요..
:
: 경험있으신 분들 조언 부탁드립니다.

+ -

관련 글 리스트
74327 Panel 안에 있는 컴포넌트 들을 마우스 Drag 로 선택하는 방법 김시환 3966 2017/04/13
74328     Re:Panel 안에 있는 컴포넌트 들을 마우스 Drag 로 선택하는 방법[자답] 김시환 4120 2017/04/13
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.