I use in my project a phgant object with the tree enabled. I have about 100 rows in my diagram and i set ganttime.style=tsUser and manage the event OnUserDrawTime (as shown in your example …Samples\ActiveX\VB6\UserDrawAndToolTip) .
After having zoom and scrolled the diagram (vertical and horizontal) many times the GantPyjamas disappears, vertical scrollbar fails and if i try to resize the tree i obtain the error “Canvas does not allow drawing”. Then the application crash.
To test this behavior create in your example UserDrawAndToolTip 100 nodes with ganttime having style tsuser, and then manipulate the diagram.
I tried this also with last patch of phgant.
What you describe is consistent with what happens if the resources allocated to draw in the OnUserDrawTime event is not properly deleted. You must make sure that pens and brushes are handled in one of two ways;
#1 Created pens and brushes in the OnUserDrawTime MUST be deleted (DeleteObject, see further info in win32 documentation). If you leave only one pen handle un-deleted your application will run out of resources if you scroll back and forth a couple of times.
#2 Keep global pens and brushes that you use to draw in the OnUserDrawTime event; in this case do not delete and do not create these objects inside the OnUserDrawTime, but rather create them in FormLoad or were appropriate.
After further investigation by Carlo he found that even when he called DeleteObject it still used up resources. Eventually he found the error: the problem was due to the declaration of function DeleteObject: in your vb example the prototypes of the API funcion DeleteObject and SelectObject are missing of ByVal keyword and so both fail (SelectObject does not return the previous handle of the object).
Public Declare Function DeleteObject Lib “gdi32” (ByVal hgdiobj As Long) As Boolean
Public Declare Function SelectObject Lib “gdi32” (ByVal HDC As Long, hgdiobj As Long) As Long
(The sample has been updated for new future releases, but you may change the module1 declaration to match the lines above)