초보 님이 쓰신 글 :
: 문의 사항 올려드립니다. 고수님들의 좋은 답변 기다리겠습니다. (__)
:
: StringGrid에서 이미지 data들을 DragDrop을 하려고 합니다.
: StringGrid에 순수 보여지는 이미지는 옮겨지는데.. 실제적인 data이미지는 옮겨지지가 않네요.
:
: exam)
: a.jpg
: b.jpg
: 이 소스로 DragDrop 했을 시.
: b.jpg
: a.jpg
: 문제는 실제적인 데이타는 옮겨지지 않는다는 겁니다.
:
: 제가 Index와 Temp간의 연결을 잘 못한건가요?
:
:
: void __fastcall TfrmSchedule::sgScheduleMouseMove(TObject *Sender,
: TShiftState Shift, int X, int Y)
: {
: // 드래그 풀기
: if(Shift.Contains(ssLeft) )
: {
: sgSchedule->MouseToCell(X,Y,ADragCol,ADragRow);
: sgSchedule->BeginDrag(true,0);
: }
: }
:
:
: void __fastcall TfrmSchedule::sgScheduleDragOver(TObject *Sender,
: TObject *Source, int X, int Y, TDragState State, bool &Accept)
: {
: int ARow,ACol;
: sgSchedule->MouseToCell(X,Y,ACol,ARow);
:
: if(ARow==ADragRow)Accept=false;
: else Accept=true;
: }
:
:
: void __fastcall TfrmSchedule::sgScheduleDragDrop(TObject *Sender,
: TObject *Source, int X, int Y)
: {
: //드래그 드랍
: SCHEDULEREC schTemp;
: int ADropRow,ADropCol;
: int nIndex;
: sgSchedule->MouseToCell(X,Y,ADropCol,ADropRow);
:
: TStringList *lst=new TStringList;
: lst->Assign(sgSchedule->Rows[ADragRow]);
: sgSchedule->Rows[ADragRow]->Assign(sgSchedule->Rows[ADropRow]);
: sgSchedule->Rows[ADropRow]->Assign(lst);
:
: // 요 아래 부분을 어떻게 수정해야 할지 답답하네요~
: memcpy(&schTemp, &Schdule[nIndex], sizeof(SCHEDULEREC));
: memcpy(&Schdule[nIndex], &Schdule[nIndex], sizeof(SCHEDULEREC));
: memcpy(&Schdule[nIndex], &schTemp, sizeof(SCHEDULEREC));
:
: SelScheduleGridPreview(&Schdule[nIndex], nIndex);
: SelScheduleGridPreview(&Schdule[nIndex], nIndex);
:
: sgSchedule->Row = nIndex;
:
: delete lst;
: }
:
위 코드에서 memcpy 할때 nIndex 값에 쓰레기 값이 들어가 있을듯 한데요..
//윗쪽에서 nIndex의 값을 설정해준적이 없으므로 쓰레기값이 nIndex에 들어있음
//accessViolation이 날수있음
memcpy(&schTemp, &Schdule[nIndex], sizeof(SCHEDULEREC));
//nIndex 가 설정되어있더라도 Source와 Destination이 같네요.. 아무 의미 없는 코드인듯...
memcpy(&Schdule[nIndex], &Schdule[nIndex], sizeof(SCHEDULEREC));
memcpy(&Schdule[nIndex], &schTemp, sizeof(SCHEDULEREC));
SelScheduleGridPreview(&Schdule[nIndex], nIndex);
SelScheduleGridPreview(&Schdule[nIndex], nIndex);
위에서 nIndex 대신에 ADragRow 와 ADropRow 를 써야 할듯 한데요
// Schdule 배열이 어떻게 되어있는지 모르니 맞는지 모르겠찌만..
// 대충 아래와 같이 하는것이 원하시는것이 아닌가 하는 생각이 드네요
memcpy(&schTemp, &Schdule[ADragRow ], sizeof(SCHEDULEREC));
memcpy(&Schdule[ADragRow ], &Schdule[ADropRow ], sizeof(SCHEDULEREC));
memcpy(&Schdule[ADropRow ], &schTemp, sizeof(SCHEDULEREC));
SelScheduleGridPreview(&Schdule[ADragRow ], ADragRow );
SelScheduleGridPreview(&Schdule[ADropRow ], ADropRow );
그럼...