10907 : How can I render a custom link when I set the link style to tlsUserDraw?


How can I render a custom link when I set the link style to
tlsUserDraw. Can you supply an example please?


The first thing to do is to create the link and set its style to User:

Private Sub LinkTimes(theFrom As IphDataEntity_GantTime, theTo As IphDataEntity_GantTime)< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Dim aLink As IphDataEntity_Link

Dim aInt As Integer


   If (theFrom Is Nothing) Or (theTo Is Nothing) Then

     ‘ Dont do anything


     Set aLink = phGantX1.AddLink


     aLink.LinkOwner = theFrom

     aLink.LinkedTo = theTo


     aInt = globalCounter Mod 4

     ‘aLink.LinkStyle = tlsMSProject

     aLink.LinkStyle = tlsUserDraw


     aLink.LinkColor = vbBlue


     If aInt = 1 Then

       aLink.StartFinishOption = tlsfFS

     ElseIf aInt = 2 Then

       aLink.StartFinishOption = tlsfSS

     ElseIf aInt = 3 Then

       aLink.StartFinishOption = tlsfFF

     ElseIf aInt = 3 Then

       aLink.StartFinishOption = tlsfFS

     End If

     globalCounter = globalCounter + 1

   End If

   Set globalToLinkTo = theTo

End Sub


And then you must implement the OnUserDrawLink event and simply draw your link between the start and stop. Mind you that this sample only draws a straight line, and the implementations in the phGantTimePackage does a lot more to bend the line etc.




Private Sub phGantX1_OnUserDrawLink(ByVal theGant As phGantXControl.IphGantX2, ByVal theDataEntity_Link As phGantXControl.IphDataEntity_Link, ByVal theHDC As Long, ByVal Startx As Long, ByVal Starty As Long, ByVal Stopx As Long, ByVal Stopy As Long)

    aDummy = Module1.MoveTo(theHDC, Startx, Starty)

    aDummy = Module1.LineTo(theHDC, Stopx, Stopy)


End Sub




Leave a Reply