确定文本如何完成。
命名空间: Microsoft.VisualStudio.TextManager.Interop
程序集: Microsoft.VisualStudio.TextManager.Interop(在 Microsoft.VisualStudio.TextManager.Interop.dll 中)
语法
声明
Function OnCommit ( _
pszSoFar As String, _
iIndex As Integer, _
fSelected As Integer, _
cCommit As UShort, _
<OutAttribute> ByRef pbstrCompleteWord As String _
) As Integer
int OnCommit(
string pszSoFar,
int iIndex,
int fSelected,
ushort cCommit,
out string pbstrCompleteWord
)
int OnCommit(
[InAttribute] String^ pszSoFar,
[InAttribute] int iIndex,
[InAttribute] int fSelected,
[InAttribute] unsigned short cCommit,
[OutAttribute] String^% pbstrCompleteWord
)
abstract OnCommit :
pszSoFar:string *
iIndex:int *
fSelected:int *
cCommit:uint16 *
pbstrCompleteWord:string byref -> int
function OnCommit(
pszSoFar : String,
iIndex : int,
fSelected : int,
cCommit : ushort,
pbstrCompleteWord : String
) : int
参数
pszSoFar
类型:String[in] 类型化到目前为止文本。
iIndex
类型:Int32[in] 标识匹配完成项设置项的索引。
fSelected
类型:Int32[in] 指示完成项是否在完成框中选择。 如果 true, pszSoFar 参数的值。 GetDisplayText返回的文本然后替换。 如果 true,这指示 S_OK 返回与 pbstrCompleteWord 的值设置为等于 pszSoFar 适合的默认行为。 fSelected 的默认值为 true。
cCommit
类型:UInt16[in] 类型化的最后一个字符。
pbstrCompleteWord
类型:String%[out] 返回完整单词。
返回值
类型:Int32
如果方法成功,则返回 S_OK。如果失败,它会返回一个错误代码。
备注
COM 签名
从 textmgr.idl:
HRESULT IVsCompletionSet::OnCommit(
[in] const WCHAR *pszSoFar,
[in] long iIndex,
[in] BOOL fSelected,
[in] WCHAR cCommit,
[out] BSTR *pbstrCompleteWord
);
语句完成的时间和方式提交到文本,请执行此方法自定义。
,如果用户按任意标准完成字符,默认行为会导致的。 标准完成字符是任何非字母数字字符。 “~”和 “_"”。 ,仅当一种最佳匹配的文本项在语句完成中放置当前选定列表框,文本替换发生在提交。 它是目前替换键入的文本中的文本。
,仅当 CSF_CUSTOMCOMMIT 的值为完成标志设置为,指定调用此方法。 ,在语句完成处于活动状态时,此方法对于每个字符一次调用用户类型。
如果此方法返回 S_FALSE,不使发生,但字符插入作为常规 (非完成的) 字符。
备注
不要返回 S_FALSE ,如果该字符是 选项 或 CTRL-ENTER,,因为这些强制使大小写。
如果此方法返回 S_OK,使所生成。 如果 fSelected 是 true至此,则在 pbstrCompleteWord 返回的值替换键入的文本。 如果 fSelected 是 false 或返回的 pbstrCompleteWord 值为 nullnull 引用(在 Visual Basic 中为 Nothing),则为现有文本不会替换在提交。
示例
下面是 OnCommit 方法的示例。
STDMETHODIMP CFigStatementCompletion::OnCommit(
/*[in] */ const WCHAR *pszSoFar,
/*[in] */ long iIndex,
/*[in] */ BOOL fSelected,
/*[in] */ WCHAR cCommit,
/*[out]*/ BSTR *pbstrCompleteWord )
{
if (IsCharAlphaNumeric(cCommit) || cCommit == ':' || cCommit == '_')
{
// continue trying to match without completion
return S_FALSE;
}
if (null == pbstrCompleteWord)
return E_POINTER;
*pbstrCompleteWord = SysAllocString(m_vecCompletions[ iIndex ]);
return S_OK;
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。