MOA Developer's Guide
MOA Interfaces | MOA Methods | MOA Types and Misc API

Director Xtra Development Kit: MOA Developer's Guide

Frequently Asked Questions


How do I choose a value for a class or interface ID?
Currently there's only one "safe" way to do it: use a utility that generates a random one based on (among other things) your machine's Ethernet address and the date/time. Since all Ethernet adapters are supposed to have unique IDs, this should in theory be safe. Microsoft provides the utilities on Windows machines; we wrote a similar one of our own for Macintosh classic. Apple provides a terminal command with OS X. Feel free to use any random values you like during development, but prior to release, you must get a "real" value from such a utility. More details.

I get link errors saying that CLSID_xxx or IID_xxx are missing (or duplicate). What gives?
The macro DEFINE_GUID normally makes an "extern" declaration of the MoaID structure. However, if the macro INITGUID is defined, the DEFINE_GUID macro actually declares the identifier. So... to make your files link correctly, you need to place #define INITGUID at the top of exactly one file, before including any header files.

How do I access resources within my Xtra?
On the Mac, your Xtra may or may not have its resource file open at any given time. To avoid unnecessary resource-file openings (which would be uncool because it's a slow operation), we've set up a way for you to hook in to the possibly-already-open file. There are two calls in the PIMoaCallback for doing so, MoaBeginUsingResource() and MoaEndUsingResources(). Your Xtra will have a global called gXtraFileRef; this is not a resource file reference number, but a magic token used to get it for you. To get the resource file reference number and make it the topmost in the resource chain, call MoaBeginUsingResources(), then use Get1xxx to get your resources. When you are done, call MoaEndUsingResource(); this will possibly close the resource file (note that the resource file is always opened read-only). You'll also have to pass in a scratch variable that's used to save and restore the same resource-chain state.

A bit of code example:

XtraResourceCookie myCookie, saveCookie;

myCookie = This->pCallback->lpVtbl->MoaBeginUsingResources(This->pCallback, gXtraFileRef, &saveCookie);
h = Get1NamedResource(...);
This->pCallback->lpVtbl->MoaEndUsingResources(This->pCallback, gXtraFileRef, saveCookie);

Under Windows, the same rigmarole is used; the main difference is that an "XtraResourceCookie" is really just an HINSTANCE to your Xtra's DLL.

I can't create any instances of my Xtra; I always get an error. What is wrong?
Likely problem is you didn't export all the necessary functions (if you are using CFM or DLL). Or perhaps your Xtra is using a supporting DLL or shared library that isn't available.
How do I find the folder where my Xtra is located?
Macintosh:
{
	FSSpec mySpec;
	MoaError err;
	PIMoaPathName pMoaFile;
	MoaChar chXtraFolder[512];
	err = pObj->pCallback->MoaCreateInstance(&CLSID_CMoaPath, &IID_IMoaPathName, (PPMoaVoid)&pMoaFile);
	err = FSMakeFSSpec( ((FSSpecPtr)gXtraFileRef)->vRefNum, ((FSSpecPtr)gXtraFileRef)->parID , "\p", &mySpec);
	err = pMoaFile->InitFromFSSpec(&mySpec);
	err = pMoaFile->GetPath(chXtraFolder, 512);
	err = pMoaFile->Release();
 }
Windows:
{
  	XtraResourceCookie pSaveCookie, pNewCookie = NULL;
	DWORD dwErr;
	MoaChar chXtraFolder[MAX_PATH];
	pNewCookie = pObj->pCallback->MoaBeginUsingResources(gXtraFileRef, &pSaveCookie);
	if (pNewCookie)
	{
		dwErr = GetModuleFileName(pNewCookie, chXtraFolder, MAX_PATH);
		pObj->pCallback->MoaEndUsingResources(gXtraFileRef, pSaveCookie);
		if (dwErr!=0)
		{
			int n;
			int nLen = strlen(chXtraFolder);
			for (n=nLen; n>0; n--)
			{
				if (chXtraFolder[n-1] == '\\')
					break;
				else
					chXtraFolder[n-1] = '\0'; // clear character
			}
		}
	}
}

Copyright © 1995-2008 Adobe Macromedia Software LLC, Inc.