2

我已经使用 .NET 4.0 为 Windows 资源管理器实现了一个自定义属性处理程序。除了具有多个值的列显示在由“;”分隔的同一行之外,一切正常。我尝试将 drawControl 的控件属性设置为 Default、MultiLineText 和 MultiValueText,但仍然没有成功。我想要实现的是将每个值放在单独的行上,而不是用“;”分隔。

这是我注册的propdesc文件的propertyDescription:

<propertyDescription name="Test.Property" formatID="{A5D0A4B0-EC4D-43DA-86F6-55448D9E9430}" propID="555">
  <description>Description</description>
  <searchInfo inInvertedIndex="True" isColumn="True" columnIndexType="OnDisk"/>
  <typeInfo type="Any" multipleValues="True" isViewable="True" isQueryable="True" isInnate="False"/>
  <labelInfo label="Test Property"/>
  <displayInfo displayType="String" mnemonics="testproperty">
    <drawControl control="MultiLineText" />
  </displayInfo>
</propertyDescription>

下面是 IPropertyStore 接口的 GetValue 方法的实现:

[DllImport("propsys.dll", CharSet = CharSet.Unicode, SetLastError = true)]
    internal static extern void InitPropVariantFromStringVector([In, Out] string[] prgsz, uint cElems, out PropVariant ppropvar);

public int GetValue(ref PropertyKey key, out PropVariant pv)
{

    pv = new PropVariant();
    pv.variantType = (short)(VarEnum.VT_VECTOR | VarEnum.VT_LPWSTR);
    string[] stringArray = new string[] { "Test1", "Test2" };
    InitPropVariantFromStringVector(stringArray, (uint)stringArray.Length, out pv);
    return HR_OK;
}
4

0 回答 0