共用方式為


IVsHiColorItem.GetColorData 方法

擷取指定之項目的 RGB 值。

命名空間:  Microsoft.VisualStudio.TextManager.Interop
組件:  Microsoft.VisualStudio.TextManager.Interop.8.0 (在 Microsoft.VisualStudio.TextManager.Interop.8.0.dll 中)

語法

'宣告
Function GetColorData ( _
    cdElement As Integer, _
    <OutAttribute> ByRef pcrColor As UInteger _
) As Integer
int GetColorData(
    int cdElement,
    out uint pcrColor
)
int GetColorData(
    [InAttribute] int cdElement, 
    [OutAttribute] unsigned int% pcrColor
)
abstract GetColorData : 
        cdElement:int * 
        pcrColor:uint32 byref -> int
function GetColorData(
    cdElement : int, 
    pcrColor : uint
) : int

參數

  • cdElement
    類型:Int32

    [in]介於__tagVSCOLORDATA列舉型別識別為其取得色彩的項目。

  • pcrColor
    類型:UInt32%

    [] out要求的 RGB 值。

傳回值

類型:Int32
如果成功的話,會傳回S_OK。 否則,會傳回錯誤碼。

備註

COM 簽章

從 textmgr2.idl

interface IVsHiColorItem : IUnknown
    {
        HRESULT GetColorData([in] VSCOLORDATA cdElement,
                             [out] COLORREF* pcrColor);
    };

請注意傳回的 RGB 值是 Win32 COLORREF的值。

在 managed 程式碼,RGB 值轉換成COLORREF的程式碼的值:

    uint colorRef = (uint)System.Drawing.ColorTranslator.ToWin32(
                              System.Drawing.Color.FromArgb(r, g, b));

在 unmanaged 程式碼,使用RGB巨集以建立COLORREF的值,例如, RGB(0x00, 0xff,0x00)。

.NET Framework 安全性

請參閱

參考

IVsHiColorItem 介面

Microsoft.VisualStudio.TextManager.Interop 命名空間