void AppDataTest::PutAppData() { 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; } // Load the text out of the edit field into a buffer int text_len = GetWindowTextLength(GetDlgItem(hPanel,IDC_APPDATA_EDIT))+1; TSTR theText; theText.Resize(text_len); GetWindowText( GetDlgItem(hPanel,IDC_APPDATA_EDIT), theText.dataForWrite(), text_len); MaxSDK::Util::MaxString m_string; theText.ToMaxString(m_string); const char* a_string = m_string.ToUTF8(); size_t len = strlen(a_string)+4; // 3 for UTF8 BOM, one for null char* buf = (char*)MAX_malloc(len); strcpy(buf, "\xef\xbb\xbf"); // UTF8 BOM strcat(buf, a_string); // Remove the chunk if it exists anim->RemoveAppDataChunk( APPDATA_TEST_CLASS_ID, UTILITY_CLASS_ID, spin->GetIVal()); // Add a chunk anim->AddAppDataChunk( APPDATA_TEST_CLASS_ID, UTILITY_CLASS_ID, spin->GetIVal(), (DWORD)len, buf); }