Exemplo n.º 1
0
void AppDataTest::GetAppData()
	{
	Animatable *anim = PickAnim();
	if (!anim) return;

	// XRef stuff 020416  --prs.
	if (s_through_xref) {
		RefTargetHandle rth = (RefTargetHandle)anim;
		IXRefItem* xi = NULL;
		while (rth != NULL && (xi = IXRefItem::GetInterface(*rth)) != NULL)
			rth = xi->GetSrcItem();
		if (rth != NULL)
			anim = rth;
	}

	// Grab the app data chunk from the anim
	AppDataChunk *ad = 
		anim->GetAppDataChunk(
			APPDATA_TEST_CLASS_ID, 
			UTILITY_CLASS_ID, 
			spin->GetIVal());
	if (ad && ad->data) {
		// Fill the edit field with the text.
		TSTR data;
		const char* raw_string = (const char*)ad->data;
		if (strncmp(raw_string, "\xef\xbb\xbf", 3) == 0)
			data = TSTR::FromUTF8(raw_string+3);
		else
		{
			DbgAssert(!_T("Should always convert appdata in UpdateAppDataLoadProc"));
			Interface14 *iface = GetCOREInterface14();
			LANGID langID = iface->LanguageToUseForFileIO();
			UINT codePage = iface->CodePageForLanguage(langID);
			data = TSTR::FromCP(codePage, raw_string);
		}
		SetDlgItemText(hPanel,IDC_APPDATA_EDIT,data.data());
	} else {
		// Not found!
		MessageBox(hPanel,_T("No app data found"),_T("App Data Tester"),MB_OK);
		}
	}