일단 아래처럼 구현은 했는데 뭔가 좀 찜찜합니다.
일단 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 들만 특정 색으로 변경하고 싶은데
: 생각처럼 되지를 않네요..
:
: 경험있으신 분들 조언 부탁드립니다.
|