Q&A

  • 이룬~ 에러가 몽창 뜨네여 Listview 에서 Sort하는건데....
안녕하세여 Listview에서 Sort를 하는건데 최용일님께서 전에 답변한걸 이용을 했습니다. 그런데 에러가 나는데 고수님들의 따듯한 손길을 기다리고 있습니다.



procedure TFmBrowser.lvItemListColumnClick(Sender: TObject;

Column: TListColumn);

begin

lvItemList.CustomSort(CompareProc, Column.Tag);

end;



function CompareProc(lParam1, lParam2 : TListItem; lParamSort: Integer): Integer stdcall;

begin

Result := 0;

case lParamSort of

1: Result := CompareText(lParam1.Caption, lParam2.Caption);

2: Result := CompareText(lParam1.SubItems[0], lParam2.SubItems[0]);

3: Result := CompareText(lParam1.SubItems[1], lParam2.SubItems[1]);

4: Result := CompareText(lParam1.SubItems[2], lParam2.SubItems[2]);

end;

end;



이렇게 했는데 이런 에러가 나는데여

Incompatible types: regular procedure and method pointer



type 안맞는다는 얘긴가여



부탁좀 드리겠습니다.



2  COMMENTS
  • Profile
    최용일 2000.12.18 03:17
    안녕하세요. 최용일입니다.



    TListView의 CustomSort메소드의 파라메터로 들어가는 함수는 콜백함수입니다.



    아래처럼 메소드 내부에서 함수를 선언해서 사용하세요... 그럼 될겁니다.



    쩝~ 안되면 메일주세요...



    ^^ 항상 즐코하세요...



    procedure TFmBrowser.lvItemListColumnClick(Sender: TObject;

    Column: TListColumn);



    function CompareProc(lParam1, lParam2 : TListItem; lParamSort: Integer): Integer stdcall;

    begin

    Result := 0;

    case lParamSort of

    1: Result := CompareText(lParam1.Caption, lParam2.Caption);

    2: Result := CompareText(lParam1.SubItems[0], lParam2.SubItems[0]);

    3: Result := CompareText(lParam1.SubItems[1], lParam2.SubItems[1]);

    4: Result := CompareText(lParam1.SubItems[2], lParam2.SubItems[2]);

    end;

    end;



    begin

    lvItemList.CustomSort(CompareProc, Column.Tag);

    end;



    꼴통 wrote:

    > 안녕하세여 Listview에서 Sort를 하는건데 최용일님께서 전에 답변한걸 이용을 했습니다. 그런데 에러가 나는데 고수님들의 따듯한 손길을 기다리고 있습니다.

    >

    > procedure TFmBrowser.lvItemListColumnClick(Sender: TObject;

    > Column: TListColumn);

    > begin

    > lvItemList.CustomSort(CompareProc, Column.Tag);

    > end;

    >

    > function CompareProc(lParam1, lParam2 : TListItem; lParamSort: Integer): Integer stdcall;

    > begin

    > Result := 0;

    > case lParamSort of

    > 1: Result := CompareText(lParam1.Caption, lParam2.Caption);

    > 2: Result := CompareText(lParam1.SubItems[0], lParam2.SubItems[0]);

    > 3: Result := CompareText(lParam1.SubItems[1], lParam2.SubItems[1]);

    > 4: Result := CompareText(lParam1.SubItems[2], lParam2.SubItems[2]);

    > end;

    > end;

    >

    > 이렇게 했는데 이런 에러가 나는데여

    > Incompatible types: regular procedure and method pointer

    >

    > type 안맞는다는 얘긴가여

    >

    > 부탁좀 드리겠습니다.

    >

  • Profile
    꼴통 2000.12.18 16:35
    .