// Saves note's text void CNoteDlg::SaveNoteText() { // Obtain the length of the text within the edit control int nLen = m_wndEdit.GetTextLengthEx(); if (nLen == 0) return; // Create the buffer that will receive the text TCHAR * pszText = new TCHAR[(nLen + 1) * sizeof(TCHAR)]; if (!pszText) ATLTRACE(_T("Not enough memory to allocate for the buffer.\n")); pszText[nLen * sizeof(TCHAR)] = '\0'; // Copy the text of the edit control into the buffer if (!m_wndEdit.GetTextEx(pszText, nLen + 1)) ATLTRACE(_T("GetTextEx() failed.\n")); // Set the note's test SetNoteText(pszText); delete[] pszText; // Set the note's RTF formatting code SetNoteRTF(m_wndEdit.GetRTF()); }
FloatNote * NewFloatNote (Vector3 const * pvsAnchor, char * szText) { FloatNote * psNote; psNote = g_new0 (FloatNote, 1); psNote->vsAnchor.fX = pvsAnchor->fX; psNote->vsAnchor.fY = pvsAnchor->fY; psNote->vsAnchor.fZ = pvsAnchor->fZ; psNote->vsPos.fX = 20.0f * ((float)rand () / (float)RAND_MAX); psNote->vsPos.fY = 20.0f * ((float)rand () / (float)RAND_MAX); psNote->vsPos.fZ = psNote->vsAnchor.fZ; psNote->vsVel.fX = 0.0f; psNote->vsVel.fY = 0.0f; psNote->vsVel.fZ = 0.0f; psNote->fMarginInternal = NOTE_BORDERINT; psNote->fMarginExternal = NOTE_BORDEREXT; psNote->szText = NULL; SetNoteText (psNote, szText); return psNote; }
void VaultTextNoteNode::SetVisitInfo (const plAgeInfoStruct & info) { ARRAY(wchar_t) buf; for (unsigned i = 0; i < kNumAgeInfoFields; ++i) { switch (i) { case kAgeFilename: { wchar_t src[128]; StrToUnicode(src, info.GetAgeFilename(), arrsize(src)); unsigned len = StrLen(src); wchar_t * dst = buf.New(len); memcpy(dst, src, len * sizeof(src[0])); } break; case kAgeInstName: { wchar_t src[128]; StrToUnicode(src, info.GetAgeInstanceName(), arrsize(src)); unsigned len = StrLen(src); wchar_t * dst = buf.New(len); memcpy(dst, src, len * sizeof(src[0])); } break; case kAgeUserName: { wchar_t src[128]; StrToUnicode(src, info.GetAgeUserDefinedName(), arrsize(src)); unsigned len = StrLen(src); wchar_t * dst = buf.New(len); memcpy(dst, src, len * sizeof(src[0])); } break; case kAgeDesc: { wchar_t src[128]; StrToUnicode(src, info.GetAgeDescription(), arrsize(src)); unsigned len = StrLen(src); wchar_t * dst = buf.New(len); memcpy(dst, src, len * sizeof(src[0])); } break; case kAgeInstGuid: { plUUID guid = *info.GetAgeInstanceGuid(); wchar_t src[64]; wcsncpy(src, guid.AsString().ToWchar(), 64); unsigned len = StrLen(src); wchar_t * dst = buf.New(len); memcpy(dst, src, len * sizeof(src[0])); } break; case kAgeLanguage: { wchar_t src[32]; StrPrintf(src, arrsize(src), L"%u", info.GetAgeLanguage()); unsigned len = StrLen(src); wchar_t * dst = buf.New(len); memcpy(dst, src, len * sizeof(src[0])); } break; case kAgeSequence: { wchar_t src[32]; StrPrintf(src, arrsize(src), L"%u", info.GetAgeSequenceNumber()); unsigned len = StrLen(src); wchar_t * dst = buf.New(len); memcpy(dst, src, len * sizeof(src[0])); } break; DEFAULT_FATAL(i); } wchar_t * sep = buf.New(1); *sep = L'|'; } wchar_t * term = buf.New(1); *term = 0; SetNoteText(buf.Ptr()); }