|
안녕하세요
저는 빌더를 접한지 6개월 남짓 되었구요.
현재 빌더를 이용해서 프로그램 하나를 만들고 있습니다.
잘 안되어 문의 드립니다.
제가 하고 있는 일은 AForm에 여러개의 Lable를 올려 놓고
사용자가 입맛에 따라 레이블의 위치를 드래그하여 옮길 수 있도록
하고자 합니다. 그런데 폼에 레이블은 생성했는데 드래그 할려고 특정
레이블을 선택해도 선택이 되지 않고 드래그도 안됩니다.
아시는 분 좀 도와 주십시요.
아래는 저의 소스 일부분입니다.
1. AForm에 레이블 생성 단계
AForm::makelabel() {
PSList LStruct;
TList *NList = new TList();
this->Canvas->Brush->Color = clBtnFace;
this->Canvas->FillRect(Rect(0, 0, this->Width, this->Height));
qryRNode->Close();
qryRNode->SQL->Clear();
qryRNode->SQL->Add("SELECT * ");
qryRNode->SQL->Add("From nodeinfo_view ");
qryRNode->SQL->Add("Where regioncode = :Reg ");
qryRNode->ParamByName("Reg")->AsString = "0100";
qryRNode->Prepare();
if(qryRNode->Prepared)
qryRNode->Open();
for(int i = 0; i < qryRNode->RecordCount; i++)
{
LStruct = new TSList; //각 노드들의 이름과 위치값을 저장
Node = new TLabel(this);
Node->Parent = this;
Node->Name = "Node" + IntToStr(i);
Node->DragMode = dmManual;
Node->ShowHint = true;
Node->OnClick = NodeClick;
Node->Height = 30;
Node->Width = 44;
Node->Cursor = crHandPoint;
Node->Left = qryRNode->FieldByName("left1")->AsInteger;
Node->Top = qryRNode->FieldByName("top1")->AsInteger;
Node->AutoSize = false;
Node->Caption = qryRNode->FieldByName("nodename")->AsString;
Node->Font->Size = 8;
Node->Font->Name = "굴림";
Node->WordWrap = true;
Node->Alignment = taCenter;
Node->Layout = tlCenter;
Node->Visible = true;
Node->Color = clLime;
LStruct->SoName = Node->Caption;
LStruct->SoX1 = Node->Left;
LStruct->SoY1 = Node->Top;
NodeList->Add(LStruct); //Local List에 각 지역의 노드위치정보를 저장
NList->Add(Node); //Local List에 각 지역의 노드정보를 저장
//Node_Str->Add(NodePos); //노드의 위치 저장
qryRNode->Next();
}
// 모든 TImage 컨트롤의 커서 설정
for(int j=0; j<ControlCount;j++)
{
if(Controls[j]->ClassNameIs("TLabel"))
Controls[j]->Cursor = crHandPoint;
}
}
2. Drag하는 부분
void __fastcall TAForm::FormDragOver(TObject *Sender, TObject *Source,
int X, int Y, TDragState State, bool &Accept)
{
TControl *SourceControl = dynamic_cast<TControl *>(Source);
if(SourceControl!=NULL)
{
SourceControl->Visible = false;
Accept = true;
if(X % 4 > 1)
SourceControl->Left = X - (X % 4) + 4;
else
SourceControl->Left = X - (X % 4);
if(Y % 4 > 1)
SourceControl->Top = Y - (Y % 4) + 4;
else
SourceControl->Top = Y - (Y % 4);
//드래그한 노드의 위치 저장
for(int i=0;i<NodeList->Count; i++)
{
PSList SeStruct = (PSList) NodeList->Items[i];
if (SeStruct->SoName == SourceControl->Hint) {
SeStruct->SoX1 = X;
SeStruct->SoY1 = Y;
LocalNode = true; //Local Node이면 Remote Node는 Uncheck
break;
}
}
SourceControl->Visible = true;
}
}
3. Drop하는 부분
void __fastcall TAForm::FormDragDrop(TObject *Sender, TObject *Source,
int X, int Y)
{
for(int i=0;i<NList->Count; i++)
{
((TLabel *)(NList->Items[i]))->Visible = false;
((TLabel *)(NList->Items[i]))->Visible = true;
}
}
이상 제가 현재 구현한 부분입니다.
보시고 아시는분 도움 좀 주십시요
미리 감사드립니다.
모든분들 덥고 지리한 장마속에서도 건승하시고 모든일 잘 되시길 빕니다.
그럼 모든분 화이팅
김아현 배상
|