共用方式為


IVsPackageDefinedTextMarkerType.DrawGlyphWithColors Method

Draws a glyph in the given display context and bounding rectangle using the provided colors.

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop (in Microsoft.VisualStudio.TextManager.Interop.dll)

Syntax

'宣告
Function DrawGlyphWithColors ( _
    hdc As IntPtr, _
    pRect As RECT(), _
    iMarkerType As Integer, _
    pMarkerColors As IVsTextMarkerColorSet, _
    dwGlyphDrawFlags As UInteger, _
    iLineHeight As Integer _
) As Integer
'用途
Dim instance As IVsPackageDefinedTextMarkerType
Dim hdc As IntPtr
Dim pRect As RECT()
Dim iMarkerType As Integer
Dim pMarkerColors As IVsTextMarkerColorSet
Dim dwGlyphDrawFlags As UInteger
Dim iLineHeight As Integer
Dim returnValue As Integer

returnValue = instance.DrawGlyphWithColors(hdc, _
    pRect, iMarkerType, pMarkerColors, _
    dwGlyphDrawFlags, iLineHeight)
int DrawGlyphWithColors(
    IntPtr hdc,
    RECT[] pRect,
    int iMarkerType,
    IVsTextMarkerColorSet pMarkerColors,
    uint dwGlyphDrawFlags,
    int iLineHeight
)
int DrawGlyphWithColors(
    [InAttribute] IntPtr hdc, 
    [InAttribute] array<RECT>^ pRect, 
    [InAttribute] int iMarkerType, 
    [InAttribute] IVsTextMarkerColorSet^ pMarkerColors, 
    [InAttribute] unsigned int dwGlyphDrawFlags, 
    [InAttribute] int iLineHeight
)
abstract DrawGlyphWithColors : 
        hdc:IntPtr * 
        pRect:RECT[] * 
        iMarkerType:int * 
        pMarkerColors:IVsTextMarkerColorSet * 
        dwGlyphDrawFlags:uint32 * 
        iLineHeight:int -> int 
function DrawGlyphWithColors(
    hdc : IntPtr, 
    pRect : RECT[], 
    iMarkerType : int, 
    pMarkerColors : IVsTextMarkerColorSet, 
    dwGlyphDrawFlags : uint, 
    iLineHeight : int
) : int

Parameters

  • hdc
    Type: System.IntPtr
    [in] Handle to a display device context that defines the visible region of interest.
  • iMarkerType
    Type: System.Int32
    [in] Integer containing the marker type.
  • dwGlyphDrawFlags
    Type: System.UInt32
    [in] Options for drawing the glyph in the widget margin. For a list of dwGlyphDrawFlags values, see GLYPHDRAWFLAGS
  • iLineHeight
    Type: System.Int32
    [in] Integer specifying the line height.

Return Value

Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsPackageDefinedTextMarkerType::DrawGlyphWithColors(
   [in] HDC hdc, [in] RECT *pRect, 
   [in] long iMarkerType, 
   [in] IVsTextMarkerColorSet *pMarkerColors, 
   [in] DWORD dwGlyphDrawFlags, 
   [in] long iLineHeight
);

This method is called by the environment if you specify a value of MV_GLYPH for your marker type. To use this method, draw your glyph on the visible region of interest specified by the hdc parameter within the bounding rectangle. Instead of hard coding colors, use the pMarkerColors parameter to call GetMarkerColors and return the colors from the current marker type or related markers so that you are synchronized with the user's color customizations. The reason IVsTextMarkerColorSet is used to determine colors is that some marker types use glyph colors that are different from their inline text colors and are keyed off of other markers.

Follow these guidelines when implementing DrawGlyphWithColors:

Do not draw anything outside of the bounding rectangle that returns with the pRect parameter.

Use Graphics Device Interface (GDI) primitives rather than bitmaps, because the size of a line can vary over a wide number of sizes and scaling of graphics is required. However, if you do want to use bitmaps, provide a variety of bitmap sizes so that you can stretch them to properly work on all the available line sizes that the user can set, including very large sizes for accessibility needs.

Do not draw any text in your marker for scaling purposes. Even universal symbols, like an exclamation point, are discouraged.

If you specified a value of MV_MULTILINE_GLYPH in your marker style, this function is called twice for every painting pass — once to paint the interior and tail of the glyph, and again to draw the top. The value for dwGlyphDrawFlags passed into this method indicates what to do:

If GDF_MULTILINE is not passed in, then just draw the top edge of the marker.

If GDF_MULTILINEis specified, then you have to do some computations based on other flags to fill in the marker glyph area. If GDF_BOTTOMEDGEis passed in, then uses the bottom line height's portion of the input bounding rectangle to draw a tail of the glyph. If GDF_TOPEDGE is passed in, then uses the top line height's portion to draw the top of the glyph. Any remaining room in the input bounding rectangle is the interior and should be painted by your function.

.NET Framework Security

See Also

Reference

IVsPackageDefinedTextMarkerType Interface

IVsPackageDefinedTextMarkerType Members

Microsoft.VisualStudio.TextManager.Interop Namespace