Canvas.MesureText doesn't work on Thin Client machine

Posted by: boisjols on 4 August 2017, 3:00 pm EST

  • Posted 4 August 2017, 3:00 pm EST

    We have a program we have installed on a number of machines and it that works fine on them, but for some reason on oen of the Thin Client machine (Citrix), it doesn't work.  On the newer Thin Client machine, it does work.  It seems to die right at the line (in red in the example below)
    <blockquote>cv.MeasureText "F", w, h
    </blockquote>with no error I can trap.  It does not run anything after that. I have included all the error trapping in the code sample below, is it correct?  The report does not actually use any data sources or controls, it draws directly on the canvas with TextOut and DrawPicture (The original actually draws a tree structure, but I have simplified it for this example).

    What could be wrong?

    It is called with:

        Dim rpt As arPrintTree
        Set rpt = New arPrintTree

    arPrintTree.dsr contains:

    Option Explicit
    Private cv As Canvas

    Private Sub ActiveReport_Error(ByVal Number As Integer, ByVal DESCRIPTION As DDActiveReports2.IReturnString, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, ByVal CancelDisplay As DDActiveReports2.IReturnBool)

        App.LogEvent "ActiveReport_Error:#" & Number & " - " & DESCRIPTION & " Scode:" & Scode & _
                "Source:" & Source
    End Sub
    Private Sub ActiveReport_PrintAborted()
        App.LogEvent "ActiveReport_PrintAborted()"
    End Sub
    Private Sub ActiveReport_ReportEnd()
        Me.Pages.Remove Me.Pages.Count - 1
    End Sub
    Private Sub ActiveReport_ReportStart()
        App.LogEvent "ActiveReport_ReportStart"
        Me.TOCEnabled = False
        With Me.Toolbar.Tools
            .Add "Printer Setup"
            .Item(.Count - 1).ID = 999
        End With
        Me.Printer.DeviceName = ""
        Me.ShowMessages = True
        Set cv = New Canvas
        App.LogEvent "Calling SetupCanvas"
        App.LogEvent "Calling PrintTree"
        App.LogEvent "Leaving ActiveReport_ReportStart"
    End Sub
    Private Sub SetupCanvas()
        With Me.PageSettings
            .LeftMargin = 720
            .RightMargin = 720
            .TopMargin = 720
            .BottomMargin = 720
        End With
        With Me.Printer
            cv.ForeColor = vbBlack
            cv.Font.Name = "Arial"
            cv.Font.Size = 12
            cv.Orientation = .Orientation
            cv.Height = .PaperHeight
            cv.Width = .PaperWidth
        End With
    End Sub
    Private Sub PrintTree()
        On Error GoTo PROC_ERROR
        App.LogEvent "In PrintTree"
        Dim w As Long   'font width
        Dim h As Long   'font height

        App.LogEvent "Past all declarations in PrintTree, will do intIndex loop"

        App.LogEvent "cv.Font.Size=12"
        cv.Font.Size = 12
        App.LogEvent "cv.MeasureText w=" & w & " h=" & h
        <b><font color="#ff0000">c</font><font color="#ff0000">v.MeasureText "F", w, h ' <------------ This line dies</font></b>
        App.LogEvent "TextOut"
        cv.TextOut "Test", Me.PageSettings.LeftMargin + 100, Me.PageSettings.TopMargin + 100
        App.LogEvent "Me.Pages.Insert"
        Me.Pages.Insert 0, cv
        App.LogEvent "Exiting PrintTree"

        Exit Sub

        App.LogEvent "Err.Number: " & Err.Number & " err.description:" & Err.DESCRIPTION
        Resume Next
    End Sub

  • Replied 4 August 2017, 3:00 pm EST

    We ran it with admintrator rights.  I agree it's probably a machine setting somewhere, maybe a user setting, but I don't know what to try?

    The strange thing is it works on another machine that is locked down even more, so I think it must be some sort of machine setting.

  • Replied 4 August 2017, 3:00 pm EST

    It may be when cv.Font.Size = 8.75.

    Try to modify the font size.
  • Replied 4 August 2017, 3:00 pm EST

    I tried font sizes 10, 8.75, 20, and a few others, it dies on exactly the same spot...  It's Arial font, it can be scaled, so the size should not matter much..

  • Replied 4 August 2017, 3:00 pm EST

    Hello ,

    I consider this problem with developers.

    I will let you know results as soon as possible.

    Sergey Romanov.

  • Replied 4 August 2017, 3:00 pm EST

    Hello ,

    We will try to reproduce this problem on our side.

    The tracking number of the issue is CR#23004.

    I have added your e-mail account into notification list.

    Sergey Romanov.

  • Replied 4 August 2017, 3:00 pm EST

    Hello ,

    I think that the problem relates to the user account/machine settings.

    Did you tried to execute your product with administrator rights?

    Sergey Romanov.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels