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
[58876] Re:StrringGrid의 파일을 Sorting하는데요. convert 에러가 뜨네요..
장성호 [nasilso] 1329 읽음    2009-10-23 19:57
TStringGridSortCompare  함수는

typedef
  int (_fastcall *)(TStringGridSortCompare  *)(TStringGrid *,int,int,int);

위와같이 정의되어있는데...

다음과 같이  StringGridQuickSort를 호출할때 넘겨준
StringGridQuickSort(StringGrid1, ACom, StringGrid1->FixedRows,StringGrid1->RowCount-1,SortStringProc);

SortStringProc 라는 함수는 다음과 같은 모양인가 보네요
int  _fastcall  SortStringProc (TStringGrid *,int a,int b);


즉  TStringGridSortCompare   타입과  SortStringProc  함수 파라메터가 맞지 않네요

참 ..
다름 링크를 참조해 보세요
http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=733


그럼..


미연아사랑해 님이 쓰신 글 :
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
:  HANDLE hFile;
:  char *pszFileName;
:  char *cFileName;
:  char szFileTime1[100];
:  char szFileTime2[100];
:  char szFileTime3[100];
:  int i,j,k,l;
:  AnsiString Dir = "";
:  AnsiString c;
:  SYSTEMTIME st;
:  FILETIME localTime;
:  WIN32_FIND_DATA FileInformation;
:
:   TStringList *flist = new TStringList;
:
:   //파일 Full Path 가져오기
:   GetFullFilePath(flist, Edit1->Text, Edit2->Text, true );
:   //flist->Sort(CompareProc);
:
:   i = flist->Count;
:
:   //폴더 내의 파일 개수
:   //char *szSearchPath = Dir.c_str();
:   //i = ResearchFileNumber(szSearchPath);
:
:   for(j=0;j<i;j++)
:   {
:    if(flist->Count<1)return;
:    hFile = FindFirstFile((LPCTSTR)flist->Strings[j].c_str(), &FileInformation);
:
:     StringGrid1->RowCount = i+1; //RowCount 증가
:
:     memset(szFileTime1,0x00,sizeof(szFileTime1));
:     memset(szFileTime2,0x00,sizeof(szFileTime2));
:     memset(szFileTime3,0x00,sizeof(szFileTime3));
:     // 만든 날짜
:     if(FileTimeToLocalFileTime(&FileInformation.ftCreationTime,&localTime))
:       FileTimeToSystemTime(&localTime,&st);
:       sprintf(szFileTime1,"%04d-%02d-%02d %02d:%02d:%02d",st.wYear,st.wMonth,
:       st.wDay,st.wHour,st.wMinute,st.wSecond);
:     // 수정한 날짜
:     if(FileTimeToLocalFileTime(&FileInformation.ftLastWriteTime,&localTime))
:       FileTimeToSystemTime(&localTime,&st);
:       sprintf(szFileTime2,"%04d-%02d-%02d %02d:%02d:%02d",st.wYear,st.wMonth,
:       st.wDay,st.wHour,st.wMinute,st.wSecond);
:     // 엑세스 날짜
:     if(FileTimeToLocalFileTime(&FileInformation.ftLastAccessTime,&localTime))
:       FileTimeToSystemTime(&localTime,&st);
:       sprintf(szFileTime3,"%04d-%02d-%02d %02d:%02d:%02d",st.wYear,st.wMonth,
:       st.wDay,st.wHour,st.wMinute,st.wSecond);
:     // 파일명
:      cFileName = FileInformation.cFileName;
:
:      StringGrid1->Cells[0][j+1] = szFileTime1;
:      StringGrid1->Cells[1][j+1] = szFileTime2;
:      StringGrid1->Cells[2][j+1] = szFileTime3;
:      StringGrid1->Cells[3][j+1] = cFileName;
:      }
:    delete flist;
:   FindClose(hFile);
: }
:
: 이 함수로 StringGrid에 값을 뿌렸구요..
: 이제 그 파일들을 StringGrid 안에서 sorting을 하려는 데요..
:
: void __fastcall StringGridQuickSort(TStringGrid *grid, int col, int L, int R,
:                                     TStringGridSortCompare SCompare)
: {
:  int I,J,P;
:  TStringList *TmpRow = new TStringList;
:  do
:  {
:   I=L;           //start
:   J=R;           //end
:   P=(L+R)>>1;    //middle
:
:   do
:   {
:     P;
:     while(SCompare(grid,col,I,P)<0)I++; // 처음에서 중간까지
:     while(SCompare(grid,col,J,P)<0)I++; // 끝에서 중간까지
:
:     if(I<=J)
:     {
:      TmpRow->Assign(grid->Rows[I]);
:      grid->Rows[I]->Assign(grid->Rows[J]);
:      grid->Rows[J]->Assign(TmpRow);
:      if(P==I)
:       P=J;
:      else if(P==J)
:       P=I;
:      I++;
:      J--;
:     }
:   }
:   while(I<=J);
:
:   if(L<J)
:    StringGridQuickSort(grid, col, L, J, SCompare);
:   L=I;
:   }
:   while(I);
:
:   delete TmpRow;
: }
:
: 이게 sorting함수인데  오름차순으로 정렬할 때
: StringGridQuickSort(StringGrid1, ACom, StringGrid1->FixedRows,StringGrid1->RowCount-1,SortStringProc);
: 이렇게 실행을 시키면 이런 에러가 뜹니다.
: Cannot convert 'int (_fastcall *)(TStringList *,int,int)' to 'int (_fastcall *)(TStringGrid *,int,int,int)'
: Type mismatch in parameter 'SCompare' (wanted 'int (_fastcall *)(TStringGrid *,int,int,int)', got 'int (_fastcall *)(TStringList *,int,int)')
: 무엇이 잘못된건가요..
: 아무리 들여다 봐두 못 찾겟습니다ㅜㅜ
: 도와주세요..

+ -

관련 글 리스트
58875 StrringGrid의 파일을 Sorting하는데요. convert 에러가 뜨네요.. 미연아사랑해 1008 2009/10/23
58876     Re:StrringGrid의 파일을 Sorting하는데요. convert 에러가 뜨네요.. 장성호 1329 2009/10/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.