ACAPI_Notify_CatchNewElement
주어진 타입의 요소가 생성되면 당신의 애드온이 알림을 받을지 여부를 등록 또는 등록 해제합니다.
GSErrCode ACAPI_Notify_CatchNewElement (
const API_ToolBoxItem* elemType,
APIElementEventHandlerProc* handlerProc
);
파라미터
- elemType
- [in] 당신의 애드온이 알림을 받아야 하는 요소의 타입을 지정합니다.
모든 타입의 요소들의 생성에 대한 알림을 받으려면 이 파라미터에
NULL을 전달하시면 됩니다. - handlerProc
- [in] 이 타입의 요소가 생성될 때 알림이 전송되면 호출되는 콜백 프로시저입니다.
여기에
NULL을 지정하는 것은 당신이 더 이상 알림이 필요하지 않다는 것을 의미합니다.
리턴 값
NoError- 요청한 동작을 성공적으로 완료했습니다.
APIERR_BADIDelemType파라미터가 유효하지 않은 typeID을 포함하고 있습니다.
다른 공통 API 오류들에 대해서는 API 오류 문서를 보십시오.
설명
이 함수는 API 도구 애드온이 특정 타입의 요소가 생성되는 이벤트를 캐치할 수 있게 해줍니다.
이 타입의 요소가 생성될 때마다 서버 애플리케이션은
예전에 이 이벤트에 대해 등록된 애드온이 제공한 handlerProc를 호출합니다.
만약 더이상 새로운 요소들의 생성을 캐치할 필요가 없다면, handlerProc 파라미터에 NULL을 전달하여
요구하는 요소 타입에 대한 ACAPI_Notify_CatchNewElement를 호출하여 등록을 해제하는 것을 기억하시기 바랍니다.
예제
// -----------------------------------------------------------------------------
// 요소 이벤트 핸들러 함수
// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL ElementEventHandler (const API_NotifyElementType *elemType)
{
GSErrCode err = NoError;
char msgStr[256];
char elemStr[32];
API_Elem_Head elemHead;
API_Element parentElement;
BNZeroMemory (&parentElement, sizeof (API_Element));
ACAPI_Notify_GetParentElement (&parentElement, NULL, 0);
switch (elemType->notifID) {
case APINotifyElement_New:
BNZeroMemory (&elemHead, sizeof (API_Elem_Head));
if (GetElementTypeString (elemType->typeID, elemStr)) {
if (parentElement.header.guid != APINULLGuid)
sprintf (msgStr, "### API Notify Test: %s #%d created as a copy of #%d",
elemStr, APIGuidToString (elemType->guid).ToCStr ().Get (),
APIGuidToString (parentElement.header.guid).ToCStr ().Get ());
else
sprintf (msgStr, "### API Notify Test: %s #%d created", elemStr,
APIGuidToString (elemType->guid).ToCStr ().Get ());
elemHead.guid = elemType->guid;
err = ACAPI_Element_AttachObserver (&elemHead, 0);
} else
sprintf (msgStr, "### API Notify Test: Unknown element type created");
break;
default:
err = APIERR_NOTSUPPORTED;
break;
}
if (err == NoError)
ACAPI_WriteReport (msgStr, false);
return NoError;
} // ElementEventHandler
// -----------------------------------------------------------------------------
// 애드온이 메모리에 로드된 후에 호출됨
// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL Initialize (void)
{
API_ToolBoxItem elemType_Wall = { API_WallID, 0, 0, 0 };
// catch changes in defaults for all element types
GSErrCode err = ACAPI_Notify_CatchNewElement (&elemType_Wall, ElementEventHandler);
return err;
} // Initialize
요구사항
- 버전: API 4.1 또는 이후
- 헤더: ACAPinc.h