本文整理汇总了C++中ITsStrFactoryPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ITsStrFactoryPtr类的具体用法?C++ ITsStrFactoryPtr怎么用?C++ ITsStrFactoryPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ITsStrFactoryPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AssertPtr
/*----------------------------------------------------------------------------------------------
Initialize variables prior to creating the control, i.e. create/attach a ISilDataAccess
and add TsString to cache
(may be explicitly called when created by ATL, because in this case TssEdit::Create() will
not be called)
----------------------------------------------------------------------------------------------*/
void TssEdit::PreCreate(ILgWritingSystemFactory * pwsf, int ws, ITsString * ptss,
IActionHandler * pacth)
{
AssertPtr(pwsf);
AssertPtrN(ptss);
ITsStringPtr qtss = ptss;
if (!ptss)
{
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
CheckHr(qtsf->MakeStringRgch(L"", 0, ws, &qtss));
}
if (pacth)
{
// We want actions in this edit box to be undoable.
VwUndoDaPtr quda;
quda.Attach(NewObj VwUndoDa);
CheckHr(quda->SetActionHandler(pacth));
m_qcda.Attach(quda.Detach());
}
else
{
m_qcda.Attach(NewObj VwCacheDa);
}
m_qcda->putref_WritingSystemFactory(pwsf);
m_qcda->CacheStringProp(khvoString, ktagString, qtss);
}
示例2: AssertPtrN
/*----------------------------------------------------------------------------------------------
Set the text of the control to be equal to ptss. If ptss is NULL, the edit box is cleared.
Message: FW_EM_SETTEXT.
----------------------------------------------------------------------------------------------*/
void TssEdit::SetText(ITsString * ptss)
{
AssertPtrN(ptss); // NULL can be used to clear string.
Assert(m_qcda);
ITsStringPtr qtss = ptss;
if (!ptss)
{
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
CheckHr(qtsf->MakeStringRgch(L"", 0, m_wsBase, &qtss));
}
ITsStringPtr qtssOld;
CheckHr(m_qcda->get_StringProp(khvoString, ktagString, &qtssOld));
int cchOld;
CheckHr(qtssOld->get_Length(&cchOld));
CheckHr(m_qcda->CacheStringProp(khvoString, ktagString, qtss));
int cchNew;
CheckHr(qtss->get_Length(&cchNew));
// Pretend the whole length has been deleted and the whole new inserted.
CheckHr(m_qcda->PropChanged(NULL, kpctNotifyAll, khvoString, ktagString, 0, cchNew, cchOld));
OnUpdate();
::UpdateWindow(m_hwnd);
OnChange();
}
示例3: Assert
/*----------------------------------------------------------------------------------------------
This initializes the string based after the pssl and pss have been set. It takes into
account whether the view is hierarchical or not.
@param fHier
@param pnt
----------------------------------------------------------------------------------------------*/
void AfDeFeCliRef::InitContents(bool fHier, PossNameType pnt)
{
Assert(m_hvoPssl); // This must be set prior to calling this method.
Assert(pnt < kpntLim);
SuperClass::Init(); // Initialize the superclass.
m_fHier = fHier;
m_pnt = pnt;
if (!m_pss)
return; // If the reference isn't set, we don't have anything to display.
ITsStringPtr qtss;
ITsStrFactoryPtr qtsf;
StrUni stu;
PossListInfoPtr qpli;
PossItemInfo * ppii;
int ipss;
qtsf.CreateInstance(CLSID_TsStrFactory);
GetLpInfo()->LoadPossList(m_hvoPssl, m_wsMagic, &qpli);
AssertPtr(qpli);
ipss = qpli->GetIndexFromId(m_pss);
ppii = qpli->GetPssFromIndex(ipss);
AssertPtr(ppii);
if (m_fHier)
ppii->GetHierName(qpli, stu, m_pnt);
else
ppii->GetName(stu, m_pnt);
int ws = ppii->GetWs();
qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss);
m_qtss = qtss;
qpli->AddNotify(this);
}
示例4: InitNewEmpty
/*----------------------------------------------------------------------------------------------
Initialize the data from the given file, or create a new empty string.
----------------------------------------------------------------------------------------------*/
void WpDa::InitNew(StrAnsi staFileName)
{
if (staFileName == "")
{
InitNewEmpty();
return;
}
Vector<StrUni> vstu;
ReadTextFromFile(staFileName, vstu);
HVO * prghvoPara = NewObj HVO[vstu.Size()];
for (int istu = 0; istu < vstu.Size(); istu++)
prghvoPara[istu] = istu + 2;
CacheVecProp(1, kflidStText_Paragraphs, prghvoPara, vstu.Size());
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
int enc = 100; // replace by the right number when we figure out what it is
for (istu = 0; istu < vstu.Size(); istu++)
{
StrUni stuPara = vstu[istu];
ITsStringPtr qtss;
CheckHr(qtsf->MakeStringRgch(stuPara.Chars(), stuPara.Length(), enc, &qtss));
CacheStringProp(istu + 2, kflidStTxtPara_Contents, qtss);
}
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle,stuNormal.Bstr()));
delete[] prghvoPara;
}
示例5: Assert
/*----------------------------------------------------------------------------------------------
Load the data from the given file into an empty window.
----------------------------------------------------------------------------------------------*/
void WpDa::LoadIntoEmpty(StrAnsi staFileName, WpChildWnd * pwcw)
{
Assert(staFileName != "");
int ctss;
CheckHr(get_VecSize(1, kflidStText_Paragraphs, &ctss));
Assert(ctss <= 1);
Vector<StrUni> vstu;
ReadTextFromFile(staFileName, vstu);
HVO * prghvoPara = NewObj HVO[vstu.Size()];
for (int istu = 0; istu < vstu.Size(); istu++)
prghvoPara[istu] = istu + 2;
CacheVecProp(1, kflidStText_Paragraphs, prghvoPara, vstu.Size());
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
int enc = 100; // replace by the right number when we figure out what it is
for (istu = 0; istu < vstu.Size(); istu++)
{
StrUni stuPara = vstu[istu];
ITsStringPtr qtss;
CheckHr(qtsf->MakeStringRgch(stuPara.Chars(), stuPara.Length(), enc, &qtss));
CacheStringProp(istu + 2, kflidStTxtPara_Contents, qtss);
}
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));
delete[] prghvoPara;
pwcw->ChangeNumberOfStrings(vstu.Size());
}
示例6: TrackPopupMenu
/*----------------------------------------------------------------------------------------------
This method works like TrackPopupMenu (supplying m_hwnd as the menu argument, and the
required nulls for the last two arguments), except that if we are in what's this help mode,
it instead tries to find the 'what's this' help for the selected item and displays it. If
it does this, it also calls ToggleHelpMode when done. For it to work, the cid must identify
a string containing multi-part names from which the krstWhatsThisEnabled option can be
retrieved.
@param hMenu handle to shortcut menu
@param uFlags options
@param x horizontal position
@param y vertical position
@param wsUser user interface writing system id.
@param ptpm contains the area not to overlap (defaults to NULL)
----------------------------------------------------------------------------------------------*/
BOOL AfWnd::TrackPopupWithHelp(HMENU hMenu, UINT uFlags, int x, int y, int wsUser,
TPMPARAMS * ptpm)
{
if (AfMainWnd::InHelpMode())
{
// Trackit without notifing the parent and get the command id.
bool fReturnCmd = uFlags & TPM_RETURNCMD;
uFlags |= TPM_NONOTIFY | TPM_RETURNCMD;
// Do this BEFORE we show the menu, so it shows normally.
AfMainWnd::ToggleHelpMode();
// This is dirty trick played by Windows that works because BOOL is really a short.
BOOL cid = ::TrackPopupMenuEx(hMenu, uFlags, x, y, m_hwnd, ptpm);
StrApp staMsg;
AfUtil::GetResourceStr(krstWhatsThisEnabled, cid, staMsg);
StrUni stuMsg = staMsg;
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtssMsg;
qtsf->MakeStringRgch(stuMsg.Chars(), stuMsg.Length(), wsUser, &qtssMsg);
AfContextHelpWndPtr qchw;
qchw.Attach(NewObj AfContextHelpWnd);
Point pt (x, y);
qchw->Create(m_hwnd, qtssMsg, pt);
if (fReturnCmd)
return cid;
else
return cid ? TRUE : 0;
}
else
{
return ::TrackPopupMenuEx(hMenu, uFlags, x, y, m_hwnd, ptpm);
}
}
示例7: switch
/*----------------------------------------------------------------------------------------------
This is the main interesting method of displaying objects and fragments of them.
Here a text is displayed by displaying its paragraphs;
and a paragraph is displayed by invoking its style rule, making a paragraph,
and displaying its contents.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP TestStVc::Display(IVwEnv * pvwenv, HVO hvo, int frag)
{
try
{
switch(frag)
{
case kfrText:
{// BLOCK for var skip warnings
// We need to show something, since the current view code can't handle a property
// containing no boxes.
// Review JohnT: should we show an empty string or something?
// Should we prevent the occurrence of texts with no paragraphs?
int cpara = 0;
ISilDataAccessPtr qsda;
CheckHr(pvwenv->get_DataAccess(&qsda));
if (hvo)
CheckHr(qsda->get_VecSize(hvo, kflidStText_Paragraphs, &cpara));
if (!cpara)
{
// Either we have no ST object at all, or it is empty of paragraphs. The
// current view code can't handle either, so stick something in.
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtssMissing;
CheckHr(qtsf->MakeStringRgch(L"<no paragraphs>", 15, 0, &qtssMissing));
CheckHr(pvwenv->AddString(qtssMissing));
break;
}
CheckHr(pvwenv->AddObjVecItems(kflidStText_Paragraphs, this, kfrPara));
}
break;
case kfrPara:
{ // BLOCK
// Invoke the paragraph's style rule if any
ISilDataAccessPtr qsda;
CheckHr(pvwenv->get_DataAccess(&qsda));
ITsTextPropsPtr qttp;
CheckHr(qsda->get_UnknownProp(hvo, kflidStPara_StyleRules, IID_ITsTextProps,
(void **) &qttp));
if (qttp)
CheckHr(pvwenv->put_Props(qttp));
// And make the paragraph containing the paragraph contents.
CheckHr(pvwenv->OpenParagraph());
CheckHr(pvwenv->AddStringProp(kflidStTxtPara_Contents));
CheckHr(pvwenv->CloseParagraph());
}
break;
}
}
catch (Throwable & thr)
{
return thr.Error();
}
catch (...)
{
return WarnHr(E_FAIL);
}
return S_OK;
}
示例8: ChkComArgPtr
/*----------------------------------------------------------------------------------------------
DisplayVariant is used for times and enumerations.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP CleCustDocVc::DisplayVariant(IVwEnv * pvwenv, int tag, VARIANT v, int frag,
ITsString ** pptss)
{
BEGIN_COM_METHOD;
ChkComArgPtr(pvwenv);
ChkComOutPtr(pptss);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
int ws = m_qlpi->GetDbInfo()->UserWs();
if (tag == kflidCmPerson_Gender || tag == kflidCmPerson_IsResearcher)
{
int itss = v.intVal;
int stid;
switch (tag)
{
case kflidCmPerson_Gender:
stid = kstidEnumGender;
break;
case kflidCmPerson_IsResearcher:
stid = kstidEnumNoYes;
if (itss)
itss = 1;
break;
default:
Assert(false);
break;
}
StrUni stuEnum(stid);
const wchar * pszEnum = stuEnum.Chars();
const wchar * pszEnumLim = stuEnum.Chars() + stuEnum.Length();
ITsStringPtr qtss;
//ITsStrFactoryPtr qtsf;
//qtsf.CreateInstance(CLSID_TsStrFactory);
int itssTry = 0;
while (pszEnum < pszEnumLim && itssTry <= itss)
{
const wchar * pszEnumNl = wcschr(pszEnum, '\n');
if (!pszEnumNl)
pszEnumNl = pszEnumLim;
if (itss == itssTry)
{
return qtsf->MakeStringRgch(pszEnum, (pszEnumNl - pszEnum), ws, pptss);
}
itssTry++;
pszEnum = pszEnumNl + 1;
}
// Fall-back behavior if we couldn't find a string: use the integer value.
char rgch[20];
_itoa_s(itss, rgch, 10);
StrUni stu(rgch);
return qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, pptss);
}
return SuperClass::DisplayVariant(pvwenv, tag, v, frag, pptss);
END_COM_METHOD(g_fact1, IID_IVwViewConstructor)
}
示例9: VwCustDocVc
/*----------------------------------------------------------------------------------------------
Construct the view constructor. Pass the RecordSpec of the view it is for, which allows it
to find its block specs.
ENHANCE JohnT: This is a rather low level object to know about the application and its list
of views. Should we just pass in the list of block specs?
----------------------------------------------------------------------------------------------*/
CleCustDocVc::CleCustDocVc(UserViewSpec * puvs, AfLpInfo * plpi, CleMainWnd * pcmw)
: VwCustDocVc(puvs, plpi, 0, kflidCmPossibilityList_Possibilities)
{
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
StrUni stu;
stu.Load(kstidSpaces0);
CheckHr(qtsf->MakeStringRgch(stu.Chars(), stu.Length(), m_qlpi->GetDbInfo()->UserWs(),
&m_qtssMissing));
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
// Border thickness below about 1/96 inch, a single pixel on a typical display.
CheckHr(qtpb->SetIntPropValues(ktptBorderTop, ktpvMilliPoint, kdzmpInch / 96));
// About a line (say 12 point) of white space above and below the border.
CheckHr(qtpb->SetIntPropValues(ktptPadTop, ktpvMilliPoint, 12000));
CheckHr(qtpb->SetIntPropValues(ktptMarginTop, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpMain));
CheckHr(qtpb->SetIntPropValues(ktptBorderBottom, ktpvMilliPoint, kdzmpInch / 96));
CheckHr(qtpb->SetIntPropValues(ktptPadBottom, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpMainLast));
qtpb.CreateInstance(CLSID_TsPropsBldr);
CheckHr(qtpb->SetIntPropValues(ktptMarginTop, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpMainFirst));
qtpb.CreateInstance(CLSID_TsPropsBldr);
// Border thickness below about 1/96 inch, a single pixel on a typical display.
CheckHr(qtpb->SetIntPropValues(ktptBorderBottom, ktpvMilliPoint, kdzmpInch / 96));
CheckHr(qtpb->SetIntPropValues(ktptPadBottom, ktpvMilliPoint, 12000));
CheckHr(qtpb->SetIntPropValues(ktptMarginBottom, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpMainFlat));
// And make the one for subentries.
qtpb.CreateInstance(CLSID_TsPropsBldr);
CheckHr(qtpb->SetIntPropValues(ktptPadTop, ktpvMilliPoint, 12000));
CheckHr(qtpb->SetIntPropValues(ktptBorderTop, ktpvMilliPoint, 0));
CheckHr(qtpb->SetIntPropValues(ktptMarginBottom, ktpvMilliPoint, 0));
// The value below is sort of a default for one level of indentation; it will be
// adjusted for lower levels.
CheckHr(qtpb->SetIntPropValues(ktptPadLeading, ktpvMilliPoint, kdzmpInch * 3 / 10));
CheckHr(qtpb->GetTextProps(&m_qttpSub));
CheckHr(qtpb->SetIntPropValues(ktptBorderBottom, ktpvMilliPoint, kdzmpInch / 96));
CheckHr(qtpb->SetIntPropValues(ktptPadBottom, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpSubLast));
m_qRecVc.Attach(NewObj CleRecVc);
m_qcmw.Attach(pcmw);
AddRefObj(pcmw);
PossListInfoPtr qpli;
m_qlpi->LoadPossList(pcmw->GetHvoPssl(), pcmw->AnalysisEnc(), &qpli);
m_hvoPssl = qpli->GetPsslId();
}
示例10: AssertPtr
/*----------------------------------------------------------------------------------------------
Return the what's-this help string for the Date Dialog ellipsis button.
@param pt not used.
@param pptss Address of a pointer to an ITsString COM object for returning the help string.
@return true.
----------------------------------------------------------------------------------------------*/
bool AfDeFeEdBoxBut::DeButton::GetHelpStrFromPt(Point pt, ITsString ** pptss)
{
AssertPtr(pptss);
StrApp str;
str.Load(kstidEllipsisBtnDateWhatsThisHelp); // No context help available
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
StrUni stu(str);
CheckHr(qtsf->MakeString(stu.Bstr(), m_pdee->UserWs(), pptss));
return true;
}
示例11: GetDataAccess
/*----------------------------------------------------------------------------------------------
Refresh the field from the data cache.
----------------------------------------------------------------------------------------------*/
void AfDeFeCliRef::UpdateField()
{
// Get the item info from the cache.
CustViewDaPtr qcvd;
GetDataAccess(&qcvd);
AssertPtr(qcvd);
HVO hvoPss;
CheckHr(qcvd->get_ObjectProp(m_hvoObj, m_flid, &hvoPss));
m_pss = hvoPss;
// Get the string from the poss cache.
ITsStringPtr qtss;
ITsStrFactoryPtr qtsf;
StrUni stu;
PossListInfoPtr qpli;
PossItemInfo * ppii;
int ipss;
qtsf.CreateInstance(CLSID_TsStrFactory);
int ws = m_ws;
if (m_pss)
{
GetLpInfo()->LoadPossList(m_hvoPssl, m_wsMagic, &qpli);
AssertPtr(qpli);
ipss = qpli->GetIndexFromId(m_pss);
if (ipss >= 0)
{
ppii = qpli->GetPssFromIndex(ipss);
AssertPtr(ppii);
if (m_fHier)
ppii->GetHierName(qpli, stu, m_pnt);
else
ppii->GetName(stu, m_pnt);
ws = ppii->GetWs();
}
}
qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss);
m_qtss = qtss;
// If we have an edit box, update the contents.
if (m_hwnd)
{
// Setting the property causes a recursive call to OnChange, so we want to block it
// from making a further change. (e.g., when you backspace to set the string to null
// then tab to the next field, we want it to stay null, not go to the first item in
// the list.)
m_fRecurse = true;
::SendMessage(m_hwnd, FW_EM_SETTEXT, 0, (LPARAM)m_qtss.Ptr());
}
}
示例12: object
/*----------------------------------------------------------------------------------------------
Initialize an empty document. It has a document object (always ID 1!) and one paragraph
containing (implicitly) an empty string. Style is set to Normal
Review SharonC(JohnT): what encoding should the empty string have??
----------------------------------------------------------------------------------------------*/
void WpDa::InitNewEmpty()
{
HVO hvoPara = 2;
CacheVecProp(1, kflidStText_Paragraphs, &hvoPara, 1);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtss;
int enc = 100;
CheckHr(qtsf->MakeStringRgch(L"", 0, enc, &qtss));
CacheStringProp(hvoPara, kflidStTxtPara_Contents, qtss);
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));
}
示例13: ChooserApplied
/*----------------------------------------------------------------------------------------------
The Ok button in the list chooser has been hit. Process the results from the list chooser.
@param pplc Pointer to the dialog box being closed.
----------------------------------------------------------------------------------------------*/
void AfDeFeCliRef::ChooserApplied(PossChsrDlg * pplc)
{
// Get the output values.
StrUni stu;
ITsStringPtr qtss;
ITsStrFactoryPtr qtsf;
HVO pssId;
qtsf.CreateInstance(CLSID_TsStrFactory);
pplc->GetDialogValues(pssId);
m_pss = pssId;
m_fRecurse = true;
if (pssId)
{
PossListInfoPtr qpli;
AfLpInfo * plpi = GetLpInfo();
AssertPtr(plpi);
plpi->LoadPossList(m_hvoPssl, m_wsMagic, &qpli);
AssertPtr(qpli);
int ipss = qpli->GetIndexFromId(pssId);
PossItemInfo * ppii = qpli->GetPssFromIndex(ipss);
if (m_fHier)
ppii->GetHierName(qpli, stu, m_pnt);
else
ppii->GetName(stu, m_pnt);
int ws = ppii->GetWs();
qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss);
m_qtss = qtss;
::SendMessage(m_hwnd, FW_EM_SETTEXT, 0, (LPARAM)qtss.Ptr());
}
else
{
m_qtss = NULL;
::SendMessage(m_hwnd, FW_EM_SETTEXT, 0, NULL);
}
// I (KenZ) don't fully understand this. But if a user enters the chooser, and opens a
// list editor from there and adds a new item, closes the list editor, checks the new
// item in the chooser, selects OK, then moves to the next record without moving from
// the field, the added item is lost. We get ksyncPossList and ksyncAddPss sync messages
// from the list editor, but for some reason we are getting an extra ksyncPossList
// message after this method completes. That extra message is calling ListChanged which
// calls UpdateField, which reloads our temporary cache from the main cache and wipes out
// the change we just made. So until we can do something better, we'll save the changes
// here to make sure the UpdateField doesn't wipe out our change.
SaveEdit();
::InvalidateRect(m_hwnd, NULL, true);
}
示例14: AssertPtrN
void AfDeFeSt::MakeRoot(IVwGraphics * pvg, ILgWritingSystemFactory * pwsf, IVwRootBox ** pprootb)
{
AssertPtrN(pwsf);
*pprootb = NULL;
// Do we have a real text object? If not, make a fake one.
int cpara = 0;
ISilDataAccessPtr qsda = m_qcvd;
if (m_hvoText)
CheckHr(qsda->get_VecSize(m_hvoText, kflidStText_Paragraphs, &cpara));
if (!cpara)
{
// We make a dummy text that is complete enough to edit, in a separate data access
// object. On loss of focus, if this data access is dirty, we make corresponding
// real objects.
if (!m_hvoText)
m_hvoText = -1;
HVO hvoPara = -2;
m_qvcdMissing.CreateInstance(CLSID_VwCacheDa);
CheckHr(m_qvcdMissing->QueryInterface(IID_ISilDataAccess, (void **)&qsda));
m_qvcdMissing->CacheVecProp(m_hvoText, kflidStText_Paragraphs, &hvoPara,1);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtssMissing;
CheckHr(qtsf->MakeStringRgch(L"", 0, m_ws, &qtssMissing));
m_qvcdMissing->CacheStringProp(hvoPara, kflidStTxtPara_Contents, qtssMissing);
}
IVwRootBoxPtr qrootb;
qrootb.CreateInstance(CLSID_VwRootBox);
CheckHr(qrootb->SetSite(this)); // pass root site
int frag = kfrText;
IVwViewConstructor * pvvc = m_qstvc;
if (pwsf)
CheckHr(qsda->putref_WritingSystemFactory(pwsf));
CheckHr(qrootb->putref_DataAccess(qsda));
CheckHr(qrootb->SetRootObjects(&m_hvoText, &pvvc, &frag,
GetLpInfo()->GetAfStylesheet(), 1));
*pprootb = qrootb;
(*pprootb)->AddRef();
RecMainWnd * prmw = dynamic_cast<RecMainWnd *>(m_qadsc->MainWindow());
if (prmw)
prmw->RegisterRootBox(qrootb);
}
示例15: switch
/*----------------------------------------------------------------------------------------------
This processes Windows messages on the window. In general, it normally calls the
appropriate method on the edit class.
----------------------------------------------------------------------------------------------*/
bool TssEdit::FWndProc(uint wm, WPARAM wp, LPARAM lp, long & lnRet)
{
bool fRet;
switch (wm)
{
case WM_GETDLGCODE:
// This is essential when embedded in a dialog to tell the dialog manager that it
// wants to get key strokes. (We could try DLGC_WANTALLKEYS but I think we would then
// get the Tab and Return keys...we may get them anyway with this combination...)
// The last value tells Windows that when tabbing to this control we should use
// EM_SETSEL to select all the text.
lnRet = DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_HASSETSEL;
return true;
case EM_GETLINE: // Use FW_EM_GETLINE.
case EM_REPLACESEL: // Use FW_EM_REPLACESEL.
// We don't support these methods. Use the replacement TsString versions instead.
Assert(false);
lnRet = LB_ERR;
return true;
// NOTE: DO NOT send this message to a TssEdit if you want the actual text. Send the
// FW_EM_GETTEXT message instead. This method is required for TssEdit controls on a
// dialog because Windows will send the message to the control anytime the user hits a
// key.
case WM_GETTEXT:
{
ITsStringPtr qtss;
GetText(&qtss);
const wchar * pwrgch;
int cch;
HRESULT hr;
IgnoreHr(hr = qtss->LockText(&pwrgch, &cch));
if (FAILED(hr))
return true;
StrApp str(pwrgch, cch);
qtss->UnlockText(pwrgch);
lnRet = Min(cch + 1, (int)wp);
achar * psz = reinterpret_cast<achar *>(lp);
StrCpyN(psz, str.Chars(), lnRet);
}
return true;
// NOTE: You should be sending an FW_EM_SETTEXT message instead of this.
case WM_SETTEXT:
{
achar * psz = reinterpret_cast<achar *>(lp);
StrUni stu(psz);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtss;
CheckHr(qtsf->MakeStringRgch(stu.Chars(), stu.Length(), m_wsBase, &qtss));
SetText(qtss);
}
return true;
case EM_CANUNDO:
case EM_CHARFROMPOS:
case EM_EMPTYUNDOBUFFER:
case EM_FMTLINES:
case EM_GETFIRSTVISIBLELINE:
case EM_GETHANDLE:
case EM_GETMODIFY:
case EM_GETPASSWORDCHAR:
case EM_GETRECT:
case EM_GETTHUMB:
case EM_GETWORDBREAKPROC:
case EM_POSFROMCHAR:
case EM_SETHANDLE:
case EM_SETMODIFY:
case EM_SETPASSWORDCHAR:
case EM_SETRECT:
case EM_SETRECTNP:
case EM_SETTABSTOPS:
case EM_SETWORDBREAKPROC:
case EM_UNDO:
case WM_GETFONT:
case WM_SETFONT:
// We don't support these methods.
Assert(false);
lnRet = LB_ERR;
return true;
case EM_GETLIMITTEXT:
lnRet = GetLimitText();
return true;
case FW_EM_GETLINE:
lnRet = GetLine(wp, (ITsString **)lp);
return true;
case EM_GETLINECOUNT:
lnRet = GetLineCount();
return true;
case EM_GETMARGINS:
//.........这里部分代码省略.........