10065 : Is it possible to make in the same TimeItem 2 different colors or shapes?

Question

Is it possible to make in the same TimeItem 2 different colors or shapes? Example to indicate the 25% completed?

Answer

You can do this with user draw, and implement any custom drawing of a time item;

Below is samples that show user draw for both phGantTimePackage and GTP.NET

 

In the phGantTimePackage you can use this code:

aGantTime.Style = tsUser ‘ Must be tsUser for the OnUserDrawTime to fire

< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

Private Sub phGantX1_OnUserDrawTime(ByVal theGant As phGantXControl.IphGantX, ByVal theDataEntity As phGantXControl.IphDataEntity_GantTime, ByVal theHDC As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)

    Dim aRect As Module1.RECT

    aRect.Bottom = Bottom

    aRect.Top = Top

    aRect.Right = Right

    aRect.Left = Left

   

    aBrush = Module1.CreateHatchBrush(4, ColorConstants.vbGreen)

    aDummy = Module1.FillRect(theHDC, aRect, aBrush)

    DeleteObject (aBrush)

   

    aBrush = Module1.CreateHatchBrush(4, ColorConstants.vbBlack)

    aDummy = Module1.FrameRect(theHDC, aRect, aBrush)

    DeleteObject (aBrush)

   

    ‘ you can draw stuff here

   

End Sub

 

In GTP.NET you can use this code:

      ti.TimeItemLayout.TimeItemStyle=TimeItemStyle.User; // Must be TimeItemStyle.User for OnTimeItem_UserDraw to fire

 

      private void gantt1_OnTimeItem_UserDraw(PlexityHide.GTP.Gantt aGantt, PlexityHide.GTP.TimeItemEventArgs e)

      {

        if (e.TimeItem.UserReference is BreakInfo)

        {

          BreakInfo breakInfo=e.TimeItem.UserReference as BreakInfo;

         

                          

        DateTime breakStart=e.TimeItem.Start.AddDays(breakInfo.startsDaysFromStart)+e.Diff;

        DateTime breakStop=breakStart.AddDays(breakInfo.breakLengthInDays);

         

        int breakStartPixel=gantt1.DateScaler.TimeToPixel(breakStart);

        int breakStopPixel=gantt1.DateScaler.TimeToPixel(breakStop);

       

       

        e.G.FillRectangle(new SolidBrush(Color.Blue),new Rectangle(e.Rect.Left,e.Rect.Top,breakStartPixel-e.Rect.Left,e.Rect.Height));

        e.G.FillRectangle(new SolidBrush(Color.Blue),Rectangle.FromLTRB(breakStopPixel,e.Rect.Top,e.Rect.Right,e.Rect.Bottom));

        e.G.DrawRectangle(new Pen(Color.Black),e.Rect);

         

         

        }

        else

        {

           e.G.DrawArc(new Pen(Color.RosyBrown,4),e.Rect,0,180);

           e.G.DrawArc(new Pen(Color.PowderBlue,6),e.Rect,180,180);

         }

      }

 

 

10062 : How in VB6 do you iterate through the nodes/cells of the tree view

Question

How in VB6 do you iterate through the nodes/cells of the tree view located on the left.

I cant seem to find any structure which says something like:

For each node in treeviewnodes
     Node.cell0 = “”
     Node.cell1 = “”
     Node.cell2 = “”
Next

Answer

Like this:

Private Sub CommandIterate_Click()< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Dim activity As IphDataEntity_Tree

 

    Set activity = Nothing

    IterateActivity phGantX1.RootDataEntitiesTree, activity

   

   

End Sub

 

Public Sub IterateActivity(aphDataList As IphDataList, aOwner As IphDataEntity_Tree)

Dim activity As IphDataEntity_Tree2

   

        For i = 0 To aphDataList.Count – 1

            Set activity = aphDataList.Items(i)

                       

            For ii = 0 To phGantX1.GridColumnCount – 1

               

                Dim s As String

                s = phGantX1.GetGridCellString(ii, activity.GridRowIndex)

                        

            Next

           

           

            IterateActivity activity.SubDataList, activity ‘ traverse owned nodes

        Next

       

 

End Sub

 

10059 : I cant get anything display in the grid when using Windows 98.

Question

I have a problem while using the grid. It seems that since I downloaded the latest available version, I cant get anything display in the grid when using Windows 98. Do you have any information about how to solve this problem ?

Answer

This was an issue that was fixed in a recent patch. Download it here : http://www.plexityHide.com/pub/phGantXControl.zip

10057 : Zooming phGant

Question

Currently evaluating the PHGantTimePackage for VB6 and would like to know how you can zoom in and out programatically without having to drag the scaler left and right?

Answer

For starters you just set the Gantt.Start and Gantt.Stop to values of your liking and the view will adapt.

You can also use the function IphGantX3.AnimateScaleTransition(newScale,steps). The scale is basically a decimal value that is calculated by (Stop-Start)/WidthInPixels  So if you want to zoom out, to show more time, you can do Gantt.AnimateScaleTransition(Gantt.Scale*2,50). And to show less time Gantt.AnimateScaleTransition(Gantt.Scale/2,50)

To get a feel for the AnimateScaleTransition you can check the Gantt.Scale property… As you zoom this parameter changes. Zoom to year and check the value of Scale. Zoom to weeks and check the value of Scale.

Now add two buttons “Year” and “Weeks”, in each button you call AnimateScaleTransition(value,50) where value is the for year and weeks respectivly, You will see how to scale animates the transition from the current setting to the year or week setting in 50 steps.

 

10049 : Hiding a time item

Question

I m using phGantTimePackage and I would like to know how to hide a time item. I tried to set Visible property to false, but the gant item does not dissapear.

Answer

The Visible feature is regretfully not implemented for time item. You will need to remove the time item, and later create it, or move it it time. One suggestion is to add ten years to the start date 

 

10046 : converting a program from vb6 to vb.net. Everything seems to go fine, exept for the userdraw ackground part.

Question

i am converting a program from vb6 to vb.net. Everything seems to go fine, exept for the userdraw ackground part. I know how to create graphics in .net But the function returns a Hdc and how can i convert this to a graphic object (so i can paint a today line for example).

Answer

You can convert a Hdc to a Graphic object like in the sample below.

private void axphSchemaX1_OnUserDrawTime(object sender, AxphGantXControl.IphSchemaXEvents_OnUserDrawTimeEvent e)
{
  Graphics gr=System.Drawing.Graphics.FromHdc((IntPtr)e.theHDC);
 
gr.DrawLine(new Pen(Color.Beige,5),e.left,e.top,e.right,e.bottom);
  gr.DrawLine(
new Pen(Color.BlueViolet,5),e.right,e.top,e.left,e.bottom);
}

10045 : The function (COM) MousePositionGantArea returns 0,0 for the last known mouseposition.

Question

I’ve returned from a 2-year, 18,000 mile bicycle tour of South American Bicycle and find myself working at the same company. I’ve been tasked to build yet another scheduling application.

I’m using some code that I had developed back in 2000. All works fine except for one thing.

The function (COM) MousePositionGantArea returns 0,0 for the last known mouseposition. Do you know if there is a problem using this method on Windows XP?

Answer

We made a code breaking change here at one point (totally against our policy and it will not happen again (?!)). The change we made was to switch from using reference integer values, to reference Variant values as parameters for the call.

We made this change to allow the call to made from VB-Script that only supports Variants as return parameters.

So you need to change the code from

dim x,y as int

to

dim x,y as Variant

 

10040 : PrintToHdc resolution

Question

Im testing the phGantTimePackage3.0 for an eventually use in one of my applications. After trying some features I have a big problem with the “PrintToHdc”-function. The hDC (Device Context) of the printer have a resolution of 300×300 dpi. I get the resolution of the hDC by the following command (in a vba-script)
  dpiX = apiGetDeviceCaps(hDC, LOGPIXELSX)

It returns 300.

The PrintToHDC function now returns the correct width and height off the gantt-chart in pixels (e.g. 4000x3000pixels) if it would be print with a resolution of 300 dpi, but on the print-preview and also on the printout the gantt-chart is printed with the resolution of the display (96x96dpi) and not of the printed-hdc resolution.

The problem is, that the viewable size of the printout is limited to the 4000×3000 pixels, but of the fact that the print was made in a resolution of 96X96 dpi the print shoult be much bigger. But only a small part of the printout (4000×3000 pixel) is seen.

Answer

You need to adjust the scale you send into the PrintToHdc. In Yapp the project calculator we use aScale=dpiX/100. This gives a scale of aproximatly 1 (0,96) for the screen preview, and on a 300 dpi printer the scale will be 3. This will give you the same degree of detail for screen and paper, but with higher resolution on the paper.

10032 : How can i Show arrows connecting two events in the gantt component? As in MS project, to show that a task begins when other is finished.

Question

How can i Show arrows connecting two events in the gantt component? As in MS project, to show that a task begins when other is finished.
Im evaluating your VCL component.

Answer

In code you do like this:

In VCL you use the method AddLink on the Gantt. This will give a a TphDataEntity_Link object that you should assign the LinkedTo and LinkOwner properties of this object, with time items (TphDataEntity_GantTime).