示例#1
0
文件: main.c 项目: dvincent/frontier
static void installhandlers (void) {

	AEInstallEventHandler ('TEST', 'smsg', NewAEEventHandlerProc (setmessageverb), 0, false);

	AEInstallEventHandler (kCoreEventClass, kAEOpenApplication, NewAEEventHandlerProc (handleopenapp), 0, false);
	
	AEInstallEventHandler (kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerProc (handleopen), 0, false);
	
	AEInstallEventHandler (kCoreEventClass, kAEPrintDocuments, NewAEEventHandlerProc (handleprint), 0, false);
	
	AEInstallEventHandler (kCoreEventClass, kAEQuitApplication, NewAEEventHandlerProc (handlequit), 0, false);
	} /*installhandlers*/
示例#2
0
文件: iappmac.c 项目: Feneric/xconq
void
init_ae()
{
	AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
					NewAEEventHandlerProc(DoOpenApp), 0L, false);
	AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
					NewAEEventHandlerProc(DoOpenDocument), 0L, false);
	AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
					NewAEEventHandlerProc(DoQuitApp), 0L, false);
	AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
					NewAEEventHandlerProc(DoQuitApp), 0L, false);

}
示例#3
0
Boolean IACinstallhandler (AEEventClass eventclass, AEEventID id, ProcPtr handler) {
	
	OSErr ec;
	
	#if TARGET_API_MAC_CARBON == 1

		ec = AEInstallEventHandler (eventclass, id, NewAEEventHandlerUPP ((AEEventHandlerProcPtr) handler), 0, false);
	
	#else
	
		ec = AEInstallEventHandler (eventclass, id, NewAEEventHandlerProc (handler), 0, false);
	
	#endif
	
	IACglobals.errorcode = ec;
	
	return (ec == noErr);
	} /*AEinstallhandler*/
示例#4
0
BOOL AFXAPI AfxOleInit()
{
	_AFX_THREAD_STATE* pState = AfxGetThreadState();
	ASSERT(!pState->m_bNeedTerm);    // calling it twice?

	// Special case DLL context to assume that the calling app initializes OLE.
	// For DLLs where this is not the case, those DLLs will need to initialize
	// OLE for themselves via OleInitialize.  This is done since MFC cannot provide
	// automatic uninitialize for DLLs because it is not valid to shutdown OLE
	// during a DLL_PROCESS_DETACH.
	if (afxContextIsDLL)
	{
		pState->m_bNeedTerm = -1;  // -1 is a special flag
		return TRUE;
	}

	// first, initialize OLE
	SCODE sc = ::OleInitialize(NULL);
	if (FAILED(sc))
	{
		// warn about non-NULL success codes
		TRACE1("Warning: OleInitialize returned scode = %s.\n",
			AfxGetFullScodeString(sc));
		goto InitFailed;
	}
	// termination required when OleInitialize does not fail
	pState->m_bNeedTerm = TRUE;

	// hook idle time and exit time for required OLE cleanup
	CWinThread* pThread; pThread = AfxGetThread();
	pThread->m_lpfnOleTermOrFreeLib = AfxOleTermOrFreeLib;

	// allocate and initialize default message filter
	if (pThread->m_pMessageFilter == NULL)
	{
		pThread->m_pMessageFilter = new COleMessageFilter;
		ASSERT(AfxOleGetMessageFilter() != NULL);
		AfxOleGetMessageFilter()->Register();
	}

#ifdef _MAC
	CWinApp* pApp; pApp = AfxGetApp();
#ifndef _WINDLL
	// Mac MFC uses a static version of ole2ui which must be initialized
	if (pState->m_bNeedTerm && !::OleUIInitialize(pApp->m_hInstance,
			pApp->m_hPrevInstance, SZCLASSICONBOX, SZCLASSRESULTIMAGE))
		goto InitFailed;
#endif

	_afxPfnOleAuto = NewAEEventHandlerProc(_AfxOleAutoHandler);
	if (_afxPfnOleAuto != NULL)
	{
		AEInstallEventHandler('OLE2', 'AUTO', _afxPfnOleAuto, (long) pApp, false);
	}
#endif

	return TRUE;

InitFailed:
	AfxOleTerm();
	return FALSE;
}