|
이영수 님이 쓰신 글 :
: TreeView에서 Item Drag Drop 하는 법 좀 알켜주세요...
: listView는 있는데 TreeView는 없네요...
: DragDrop Event에서 어떤 Message를 Send 해야 되는 건지..
: 통 알수 없네요...
도움이 될진 모르겠지만,
OnDragDrop이벤트에서 Source를 분석해서 원하는 자료를 얻는것 아닌가요?
무슨 메시지를 또 보내나요??
암튼 아래는 CBuilder 도움말 발췌입니당..
드래그 & 드랍 구현(C++ Builder)
예제: FileListBox --> TreeView
1. Starting a drag operation
void __fastcallTFMForm::FileListBox1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if (Button == mbLeft) // drag only if left button pressed
{
TFileListBox *pLB = (TFileListBox *)Sender;
if(pLB->ItemAtPos(Point(X,Y), true) >= 0)
pLB->BeginDrag(bool, int);
//false: 클릭시 바로 드래그모드로 가지 않고 int만큼 마우스
//이동시 드래그를 시작한다.
//true: 바로 드래그시작한다.
}
}
}
2. Accepting dragged items (onDragOver처리)
드래그한 컨트롤을 받는 클래스에서의 처리.
void __fastcallTForm1::TreeView1DragOver(
TObject *Sender, TObject *Source,
int X, int Y, TDragState State, bool &Accept)
{
if (Source->InheritsFrom(__classid(TFileListBox)))
Accept = true;//true이면 drop을 허락한다.
}
3. Dropping items (onDragDrop처리)
void __fastcall TForm1::TreeView1DragDrop(TObject *Sender,
TObject *Source, int X, int Y)
{
if (Source->InheritsFrom(__classid(TFileListBox)))
{
TTreeNode *pNode = TreeView1->GetNodeAt(X,Y);
AnsiString NewFile = pNode->Text + AnsiString("/") +
ExtractFileName(FileList->FileName);
MoveFileEx(FileList->FileName.c_str(), NewFile.c_str(),
MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
}
}
4. Ending a drag operation ( onDragEnd )
드랍이 일어나면 드래그가 시작된 컨트롤에서 이 메시지를 받느다.
void __fastcallTFMForm::FileList1EndDrag(TObject *Sender,
TObject *Target, int X, int Y)
{
if (Target) FileList1->Update();
}
5. Customizing drag and drop with a drag object
6. Changing the drag mouse pointer
DragCursor를 바꾼다.
|