|
아래는 CallBack 함수군요.
이건 함수의 prototype이 정의되어 있는대로만 함수를 만들어 주어야 합니다.
인자를 주고 받을때의 인자를 스텍에 넣고 제거하는 방법을 규정한 것중의 하나가
__stdcall 인데, 원래 그렇게 쓰도록 되어 있으면 반드시 그렇게 써야 합니다.
안그러면 절대 컴파일 조차 안됩니다.
편법으로 컴파일하면 반드시 다운됩니다.
여기에 대해 완전한 의문을 풀려면 함수호출 규약을 찾아보시면 됩니다.
C++ 프로그래밍을 하려면 이건 몰라서는 안되는 중요한 사항입니다.
그럼..
최진호 님이 쓰신 글 :
: int __stdcall에 관한 질문입니다..
:
: 아래는 책에 나와있는 예제 입니다..(윈도우 탐색기 처럼 서브디렉토리 파일명과 폴더를 표시해 주는 프로그램 입니다)
: 예제는 볼랜드 C++ builder 정복 4.0(정태영)
: 프로젝트 파일(Explorer.BPR) 파일의 일부 입니다.----> p568
:
: 여기서 궁금한것은..왜..int__stdcall 을 써야 하는지.. 다른 함수는 왜 쓸수 없는지
:
:
:
: int __stdcall CustomSortProc(LPARAM Item1, LPARAM Item2, LPARAM ParamSort)
: {
: int iResult;
: AnsiString FItem, SItem;
:
: switch(LOWORD(ParamSort)) {
: case 0 : iResult = lstrcmp(((TListItem *)Item1)->Caption.c_str(),
: ((TListItem *)Item2)->Caption.c_str());
: break;
: case 1 : FItem = ((TListItem *)Item1)->SubItems->Strings[0];
: SItem = ((TListItem *)Item2)->SubItems->Strings[0];
: FItem = FItem.SubString(0, FItem.LastDelimiter(" ") - 1);
: SItem = SItem.SubString(0, SItem.LastDelimiter(" ") - 1);
: for (int i = 1; i < FItem.Length(); i++)
: if (FItem[i] == ',') FItem.Delete(i, 1);
: for (int i = 1; i < SItem.Length(); i++)
: if (SItem[i] == ',') SItem.Delete(i, 1);
:
: if (FItem.ToInt() > SItem.ToInt()) iResult = 1;
: else iResult = -1;
: break;
: case 2 : iResult = lstrcmp(((TListItem *)Item1)->SubItems->Strings[1].c_str(),
: ((TListItem *)Item2)->SubItems->Strings[1].c_str());
: }
: if (HIWORD(ParamSort)) return -iResult;
: return iResult;
: }
:
: 이것은 책에 나와있는 예제 입니다..
|