Private Sub CommandButton44_Click() Dim inkP As New MSINKAUTLib.InkPicture 'これが一時InkPicture 'InkP.InkEnabled = True 'https://microsoft.public.windows.tabletpc.developer.narkive.com/05mR9JoA/bounding-box-of-individual-words-in-inkpicture Dim div As InkDivider Dim divUnits As IInkDivisionUnits Dim paras As IInkDivisionUnits Dim lines As IInkDivisionUnits Dim segments As IInkDivisionUnits Dim divUnit As IInkDivisionUnit Dim para As IInkDivisionUnit Dim line As IInkDivisionUnit Dim segment As IInkDivisionUnit Set div = New InkDivider Set div.strokes = InkPicture2.ink.strokes Set res = div.Divide() Set paras = div.Divide.ResultByType(IDT_Paragraph) Set lines = div.Divide.ResultByType(IDT_Line) Set segments = div.Divide.ResultByType(IDT_Segment) 'https://docs.microsoft.com/en-us/windows/win32/api/msinkaut15/ne-msinkaut15-inkdivisiontype 'Name Description 'IDT_Segment A recognition segment. 'IDT_Line A line of handwriting that contains one or more recognition segments. 'IDT_Paragraph A block of strokes that contains one or more lines of handwriting. 'IDT_Drawing Ink that is not text. Dim rect1 As InkRectangle Dim strokes(4) As IInkStrokeDisp For Each para In paras Set rect1 = para.strokes.GetBoundingBox(IBBM_Default) inkP.InkEnabled = False Set strokes(1) = inkP.ink.CreateStroke(MakeRectangle(rect1.Left - 2, rect1.Top + 4, rect1.Right + 4, rect1.Bottom - 2), Null) With strokes(1).DrawingAttributes .FitToCurve = IsCircle .Color = RGB(0, 0, 255) End With Next For Each line In lines Set rect1 = line.strokes.GetBoundingBox(IBBM_Default) With inkP.ink Set strokes(2) = .CreateStroke(MakeRectangle(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom), Null) End With With strokes(2).DrawingAttributes .FitToCurve = IsCircle .Color = 255 End With Next For Each segment In segments Set rect1 = segment.strokes.GetBoundingBox(IBBM_Default) With inkP.ink Set strokes(3) = .CreateStroke(MakeRectangle(rect1.Left + 2, rect1.Top + 2, rect1.Right - 4, rect1.Bottom + 2), Null) End With With strokes(3).DrawingAttributes .FitToCurve = IsCircle .Color = RGB(0, 128, 0) End With Next inkP.AutoRedraw = False With inkP.ink.CreateStrokes() .Add strokes(1) .Add strokes(2) .Add strokes(3) End With inkP.AutoRedraw = True Dim hTargetWin As Long '対象のウィンドウのハンドル hTargetWin = WindowFromPoint(0, 0) 'http://rucio.a.la9.jp/main/tyukyu/tyukyu5.htm Dim r As IInkRenderer Set r = New InkRenderer Dim hDC As LongPtr ' hDC = GetDC(hTargetWin) '※1 hDC = GetDC(0) '※2 r.Draw hDC, inkP.ink.strokes ' ReleaseDC hTargetWin, hDC '※1 ReleaseDC 0, hDC '※2 End Sub