Product : Engine, Version : 5.0.1.1036, ArticleID : 41023876

HowTo : I would like to display some text under cursor while I am in a command action using render

Article41023876
TypeHowTo
ProductEngine
Version5.0.1.1036
Date Added3/1/2005
Submitted bySasa Grebenar
Keywords

Subject

I would like to display some text under cursor while I am in a command action using render

Summary

I would like to display some text under cursor while I am in a command action using Render & Drawtext

Solution

Try this code in Visual Basic 6.0:

Note : This will only work with SHX font and not TTF font.
Option Explicit

Private Declare Function SetROP2 Lib "gdi32" (ByVal hdc As Long, ByVal nDrawMode As Long) As Long

Private Sub Command1_Click()
Dim TStyle   As vdTextstyle
 
    Set TStyle = VD.ActiveDocument.TextStyles(0)
    VD.ActiveDocument.SupportPath = "C:\Path_of_SHX_files\SHX;"
    TStyle.FontFile = "txt.shx"
    VD.CommandAction.CmdLine "user"
End Sub

Private Sub VD_CommandActionDraw(ByVal Render As VDStdLib5.vdRender, ByVal Action As VDStdLib5.VdConstCmdActions, ByVal referencePoint As VDStdLib5.vdxyz, ByVal currentPoint As VDStdLib5.vdxyz, Cancel As Integer)
Dim TStyle   As vdTextstyle
Dim oldRop As Long
    
    Set TStyle = VD.ActiveDocument.TextStyles(0)
    VD.Actions.EnableTTF3dText = True
    oldRop = Render.Setrop(COPYPEN)
    SetROP2 Render.hdc, oldRop
    Render.Select_Pen VdPenSolid, 1, 0

    Render.Drawtext "x: " & CStr(Format(currentPoint.x, "###0.000")) & "  y: " & CStr(Format(currentPoint.y, "###0.000")), currentPoint.x, currentPoint.y - Render.PixelSize * 10#, 0, TStyle, Render.PixelSize * 9.2, 0, VdTextHorCenter, VdTextVerCen
    Render.Setrop INVERSE_PEN
End Sub