10199 : vertical line on the time item area, that will always show current time?

Question

Can i draw somehow a vertical line on the time item area, that will always show the current time?

Answer

you can set IphGantX3.TodayLineOnOff=true, but It is easy to do this in the Background draw event, like this

Private Sub phGantX1_OnGantAreaDrawBackground(ByVal theGant As phGantXControl.IphGantX3, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long, ByVal theHDC As Long)
Dim aRect As Module1.RECT

  x = theGant.DateToPixel(Now)
  If (x > 0) And (x < Right) Then
    aRect.Bottom = Bottom
    aRect.Top = Top
    aRect.Right = x + 1
    aRect.Left = x – 1
    aBrush = Module1.GetStockObject(7)
    aDummy = Module1.FrameRect(theHDC, aRect, aBrush)
  End If
‘Public Declare Function GetStockObject Lib “gdi32” (ByVal fnObject As Long) As Long
End Sub

10196 : How to add a list of numbers or texts to a Schema time item

Question

Anyone know how to add a list of numbers or texts to a Schema time item such that each number is on a separate line within the text box.

 I’ve tried .
 Dim X As IphDataEntity_SchemaTime
 Set X = phSchemaX1.AddSchemaTime(0)
 X.AddText “1”, 10, 10, 0
 X.AddText “2”, 10, 10, 0

Answer

But the second text overwrites the first.
 the 10’s are pixel coordinates from the top left of the time item
try
 X.AddText “1”, 10, 10, 0
 X.AddText “2”, 10, 30, 0

10177 : In VCL I want catch change of the active row in the grid to get the values of the grid level and the values of some grid columns…

Question

I have a Gantt with a GridTree with 3 levels.

I want when I change the active row of the grid tree to get the values of the grid level and the values of some grid columns. Can you tell me what event should I use and what is the exact syntax in order to achieve this?

Answer

In the VCL version:

Assign the event phGant.Grid.OnSelectionChanged and implement like this:

procedure TForm1.GridSelectionChanged(Sender: TObject);
var
  aNode:TphDataEntity_GridTreeNode;
  aBabCell:TBabCell;
begin
  if Assigned(phGant1.Grid.FocusedCell) then
  begin
    aNode:=phGant1.Grid.CellToNode(phGant1.Grid.FocusedCell)
    aNode.Level;  // Grid level
    aBabCell:=phGant1.Grid.Cell[X,aNode.AxisContentItem.ListIndex]; // Any cell in the X direction
    phGant1.Grid.GetText(aBabCell); // The text value of the cell
  end;
end;

10190 : In the VCL version, how to use onChangeDataEntity_Tree, OnContentChange_Tree?

Question

Question:In the VCL version, how to use onChangeDataEntity_Tree, OnContentChange_Tree, ….etc events, they seemed not working??? I look into the help but it was too brief to be helpful…

Answer

If you are using the Grid option, the events you must use are different; UseGridNotTree=true.
Try, for example;

phGant.Grid.GetTree.OnExpand
phGant.Grid.GetTree.OnCollapse
phGant.Grid.OnCellSelectionChanged
phGant.Grid.GetTree.OnDeleteItem
phGant.Grid.GetTree.OnInsertItem
phGant.Grid.OnEditStop
phGant.Grid.OnEditorCanModify
phGant.Grid.OnInitTreeSubDataList
phGant.Grid.OnClick
phGant.Grid.OnRightClick
phGant.Grid.OnDblClick
phGant.Grid.OnMouseDown
phGant.Grid.OnMouseUp
phGant.Grid.OnMouseMove

10347 : How to set the colour for a time item in PowerBuilder?

Question

How to set the colour for a time item in PowerBuilder?

Answer

Just like in all the Activex enabled languages you get hold of an interface for a GantTime and change the color property: IphDataEntity_GantTime2.Color. There is nothing different about PowerBuilder in this respect.

The Color property is a value of type OLE_COLOR, this value is a RGB value were Red Green and Blue have 255 possible shades and then occupy their own space in the lower three bytes in the available four of of OLE_COLOR  (r*256*256+g*256+b)

10390 : How I can find a timeitem by uservariantreference ?

Question

How I can find a timeitem by uservariantreference ?

Answer

You will need to iterate thru the Gantt chart like this in c#:

 for(int i=0;i<axphGantX1.DataList3levGantTimes().Count();i++)
  {
    phGantXControl.IphDataList2lev aList2Lev=axphGantX1.DataList3levGantTimes().get_DataList2Lev(i);
    for(int ii=0;ii<aList2Lev.Count();ii++)
    {
      phGantXControl.IphDataList aList=aList2Lev.get_DataList(ii);
      for(int iii=0;iii<aList.Count();iii++)
      {
        phGantXControl.IphDataEntity_GantTime2 aGantTime=aList.get_Items(iii) as phGantXControl.IphDataEntity_GantTime2;
        if (aGantTime.UserVariantReference==THEONEIMLOOKINGFOR)
        {
       
}
      }
    }
  }

Or in VB (the code snippets does not do it the exact same way, this code use the RowList...):
    For i = 0 To phGantX1.RowList.Count - 1  ' loop over all gantt rows
        For ii = 0 To phGantX1.RowList.GantRow(i).DataLists.Count - 1 ' loop over all layers in gantt row
            For iii = 0 To phGantX1.RowList.GantRow(i).DataLists.DataList(ii).Count - 1 'loop over all time items
                Set ti = phGantX1.RowList.GantRow(i).DataLists.DataList(ii).Items(iii)
if ti.UserVariantReference=THEONEIAMLOOKINGFOR then


End if
            Next iii
        Next ii
    Next i

 

10303 : Setting focus on the grid in phGantX

Question

I cannot get an item to be selected and highlighted using code.  When I add a new item using code I would like to have it selected so that the user can begin typing immediately to edit the text without having to select the item with the mouse. I have tried the following items:

    TreeEntity.Expanded = True
    NewProject.Expanded = True
    phGantX1.SetCurrentDataEntityTree NewProject
    phGantX1.SetGridCellSelected 0, NewProject.GridRowIndex, True
    phGantX1.GridCellFocusedX = 0
    phGantX1.GridCellFocusedY = NewProject.GridRowIndex

The best I can do is get the row to be grey but not selected with a focus rectangle ready to type.

Answer

 What is lacking seems to be the focus of the control. You can call the win32 function SetFocus to set focus to a specific windows handle. You can get the windows handle to the grid with IphGantX3.HWndGrid.

10268 : I miss the onDependencyAction-Event in the control

Question

I use the Gant-Activex-Control. I will allow a user to create dependencys in the Gant-Area. Now I miss the onDependencyAction-Event in the control.

Answer

The phGantTimePackage does not currently implement selectable links or actions on links. It does however allow for creation of links described in this article: http://plexityhide.dyndns.org/InstantKB13/Article.aspx?id=10208

The event described was however not exposed in the ocx version. This is now fixed. The following event has been added:

procedure OnDependencyAction(const theGant: IphGantX3;
                                 const theStartDataEntity: IphDataEntity_GantTime2;
                                 const theTargetDataEntity: IphDataEntity_GantTime2); dispid 208;

Get it by downloading the latest patch from here https://plexityhide.com/pub/phGantXControl.zip

 

10269 : How to use the PrintWithGrid method in Delphi 7 to print the Gantt Chart to a BmpFile or JPeg File ?

Question

How to use the PrintWithGrid method in Delphi 7 to print the Gantt Chart to a BmpFile or JPeg File ?

Answer

When you send the print to the printer you do like this:

  Printer.BeginDoc;
 TphPrintGantt.PrintWithGrid(G1,Printer.Handle,10,10,2,2,G1.TreeWidth,nil,-1,true,g1.Start,g1.Stop,g1.Width-g1.TreeWidth,g1.ScalerHeight,usedwidth,usedHeight,0,0,nil);
  Printer.EndDoc;

And the only difference when generating an image send in a different  device context (hdc).

So go like this to create a bitmap:

  Result  := TBitmap.Create;
  Result.Canvas.Lock;

  
try
    
Result.PixelFormat := pf32bit;
    Result.Width := xWidth;
    Result.Height := xHeight;
    TphPrintGantt.PrintWithGrid(G1,Result.Canvas.Handle,10,10,2,2,G1.TreeWidth,nil,-1,true,g1.Start,g1.Stop,g1.Width-g1.TreeWidth,g1.ScalerHeight,usedwidth,usedHeight,0,0,nil);
  finally
    Result.Canvas.UnLock;
    Result.Free;
  end;


 

10206 : How can I select a timeitem in the gantarea

Question

How can I select a timeitem in the gantarea by selecting an item from a combobox? ID from combobox is set in UserIntegerReference

Answer

You need to iterate the Gantt and find the time item with the correct UserIntegerReference. Once you have it you can set the Selected property to true on the time item, and if you want it focused you set IphGantX3.SetCurrentDataEntityGantArea(ti)

You can use the IphDataList3lev.FindFromUserIntegerReference to search all the time items like this

phGant.IphGantX3.AllDataEntities.FindFromUserIntegerReference(x), it will then return the first time item with x in its UserIntegerReference.

Or you can iterate thru the datastructure:

  for(int i=0;i<axphGantX1.DataList3levGantTimes().Count();i++)

  {
    phGantXControl.IphDataList2lev aList2Lev=axphGantX1.DataList3levGantTimes().get_DataList2Lev(i);
   

for(int ii=0;ii<aList2Lev.Count();ii++)

    {
      phGantXControl.IphDataList aList=aList2Lev.get_DataList(ii);
     

for(int iii=0;iii<aList.Count();iii++)

      {
        phGantXControl.IphDataEntity_GantTime2 aGantTime=aList.get_Items(iii)

as phGantXControl.IphDataEntity_GantTime2;

        aGantTime.Start=aGantTime.Start.AddDays(1);
        aGantTime.Stop=aGantTime.Stop.AddDays(1);
      }
    }