Freigeben über


Painted Event

Painted Event

Occurs when the InkOverlay object or InkPicture control has completed redrawing itself.

Declaration

[C++]

void Painted(
    [in] long hDC,
    [in] IInkRectangle* Rect
);

[Microsoft® Visual Basic® 6.0]

Public Event Painted( _
    hDC As Long, _
    Rect As InkRectangle _
)

Parameters

hDC

[in] The device context on which the event occurred.

Rect

[in] The IInkRectangle that was repainted.

Remarks

This event method is defined in the _IInkOverlayEvents and _IInkPictureEvents dispinterfaces with an ID of DISPID_IOEPainted.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example demonstrates adding a Painting and a Painted event handler to an InkOverlay object. Paint events are initiated with a command button, CommandRepaint, or by the usual Window events. The Painting event handler is invoked before the Paint event begins, and causes the Color and Width drawing attributes to be randomized before the ink is painted. The Painted event handler writes information about the number of times the paint event has occurred in a text box, Text1.

Option Explicit
Dim WithEvents theInkOverlay As InkOverlay
Dim countPaint As Integer

Private Sub CommandRepaint_Click()
    Refresh
End Sub

Private Sub Form_Load()
    Randomize
    Set theInkOverlay = New InkOverlay
    theInkOverlay.hWnd = Me.hWnd
    theInkOverlay.Enabled = True
    countPaint = 0
End Sub

Private Sub theInkOverlay_Painted( _
ByVal hDC As Long, _
ByVal Rect As MSINKAUTLib.IInkRectangle)
    Text1.Text = "InkOverlay painted " & countPaint & " times."
    countPaint = countPaint + 1
End Sub

Private Sub theInkOverlay_Painting( _
ByVal hDC As Long, _
ByVal Rect As MSINKAUTLib.IInkRectangle, _
Allow As Boolean)
    Dim theDrawingAttributes As New InkDrawingAttributes
    theDrawingAttributes.Color = RGB(Int(255 * Rnd), Int(255 * Rnd), Int(255 * Rnd))
    theDrawingAttributes.Width = Int(240 * Rnd) + 30
    theInkOverlay.Ink.Strokes.ModifyDrawingAttributes theDrawingAttributes
End Sub

Applies To