Q&A

  • 콜백함수에 대한 질문입니다.
C++ 코드를 Delphi로 바꾸는 과정에서 잘 안되는 것이 있어서 질문드립니다.


// C++ 코드

// 선언

static HRESULT WINAPI EnumSurfacesCallback(

         LPDIRECTDRAWSURFACE lpDDSurface,

         LPDDSURFACEDESC lpDDSurfaceDesc,

         LPVOID lpContext);

---------------------------------------------------------------------

// 구현

HRESULT WINAPI CSAMIPlayerApp::EnumSurfacesCallback(

         LPDIRECTDRAWSURFACE lpDDSurface,

         LPDDSURFACEDESC lpDDSurfaceDesc,

         LPVOID lpContext)

{

if (g_App.m_pddsPrimary == NULL

&& lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)

{

TRACE("SUCCESS to get the primary surface ...\n");

g_App.m_pddsPrimary = lpDDSurface;

return DDENUMRET_CANCEL;

}

SAFE_RELEASE(lpDDSurface);

return DDENUMRET_OK;

}          


---------------------------------------------------------------------

// 호출

hr = pDD->EnumSurface(DDENUMSURFACES_DOESEXIST or DDENUMSURFACES_ALL,

                                           NULL, NULL, EnumSurfacesCallback);

---------------------------------------------------------------------


// 델파이 코드


type

TForm1 = class(TForm)

.

.

.

private

.

public

.

end;


function EnumSurfacesCallback(lpDDSurface: IDirectDrawSurface;

       const lpDDSurfaceDesc: TDDSurfaceDesc; lpContext: Pointer): HResult; stdcall;


var

Form1: TForm1;


implementation


{$R *.dfm}


// 함수 원형

{=====================================================================================

TDDEnumSurfacesCallback = function (lpDDSurface: IDirectDrawSurface;

     const lpDDSurfaceDesc: TDDSurfaceDesc; lpContext: Pointer): HResult; stdcall;

{$NODEFINE TDDEnumSurfacesCallback}

{$HPPEMIT 'typedef LPDDENUMSURFACESCALLBACK TDDEnumSurfacesCallback;'}

=====================================================================================}


function EnumSurfacesCallback(lpDDSurface: IDirectDrawSurface;

       const lpDDSurfaceDesc: TDDSurfaceDesc; lpContext: Pointer): HResult;

begin

   if(lpDDSurfaceDesc.ddsCaps.dwCaps > 0)  and (DDSCAPS_PRIMARYSURFACE > 0) then

   begin

       OutputDebugString('SUCCESS to get the primary surface...');

       m_pddsPrimary := lpDDSurface;

       Result := DDENUMRET_CANCEL;

       Exit;

   end;


   lpDDSurface := nil;

   Result := DDENUMRET_OK;

end;

.

.

.

procedure TForm1.xxx(...);

begin

.

.

.


// 함수원형

{=====================================================================================

function EnumSurfaces(dwFlags: DWORD; const lpDDSD: TDDSurfaceDesc;

       lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback) :

       HResult; stdcall;

=====================================================================================}


hr := pDD.EnumSurfaces(DDENUMSURFACES_DOESEXIST or DDENUMSURFACES_ALL,

                                           lpDDSD, lpContext, @EnumSurfacesCallback);

.

.

.          

end;          



C++ 코드를 델파이로 옮긴다고 옮겼는데 작동이 되질않습니다.

브레이크 포인트를 걸어놔도 EnumSurfacesCallback 함수로 들어가질 않습니다.

제가 사용법을 잘 몰라서 그런것 같은데 어디가 잘못 되었는지 좀 봐주셨으면 합니다.
0  COMMENTS