10536 : I need is to be able to display various periods of calendar with several shifts (time periods) in a day…

Question

Hello,

My question is the same that was asked in ‘Q10066 – FAQ: I need is to be able to display various periods of calendar with several shifts (time periods) in a day..’.

My problem is that you posted a sample for GTP.Net saying that it would be the same for phGantTimePackage, but I can’t find the OnDateScalerPaintBackground or the OnTimeItemAreaScalerPaintBackground events in the phGantTime OCX.

Which event should I override to be able to paint different weekdays with different colors in the Gantt?

Thank you very much,

Answer

In phGantTimePackage you have these events in the VCL version:

TphGant.OnUserDrawBackground
TphDateScaler.OnUserDrawBackground

In the OCX version the DateScaler OnUserDrawBackground is not currently available (if you need it email support and we can expose it) but you have the phGantX.OnGantAreaDrawBackground to handle the background in the TimeItemArea.

 

10628 : Is there a way to hide the grid?

Question

We’ve been using your phGantControl OCX for a few years now, and we would like to have it displayed with no tree and no grid visible. Is there a way to hide it, and to make sure the user won’t be able to make it visible (it seem that a separator can be dragged by the user to make the tree visible).

Answer

The grid row height controls the height of the Gantt row and currently the grid must be at least a few pixels wide so that the row height can be calculated.

The best way to “hide” the grid is to put something else above it, or kidnap it and put it somewhere else (offscreen). To do this you will need the window handle of the grid and call win32 windows functions to add a control to the grid (covering it) or to move the grid.

The windows handle is reached with the IphGantX3.HWndGrid property

10407 : How can I get the height of a timeitem? or the height of a treeitem?

Question

How can I get the height of a timeitem? or the height of a treeitem?
And how can I get the count from all visible treeitems?

Answer

You can use the IphGantRow3.GetRect method to get the rectangle of the GanttRow, to get the x-coordinates you must use the DateToPixel on Start and stop.
To get all visible tree items; Iterate thru Gantt.RowList and get the IphGantRow3.GetRect for each item check if the rectangle is -1,-1,-1,-1 then that row is not on screen.

10588 : Can we make the Today line in real time?

Question

Can we make the Today line update in real time?

Currently I have to move or rescale in the DateTime scaler to get the today line to update. Could this happen in real time?

I have tried using various methods such as Invaildate etc on a timer without success.

Answer

All you need to do is to make sure the TimeItemArea gets invalidated once in a while. Add a timer and in the onTimer event go something like:

gantt1.TimeItemArea.Invalidate();

(for phGantTimePackage you can send an inavlidation message to the handle found here IphGantX3.HWndGantArea)

10578 : Time from x-coord

Question

Hi I’d like to ask, how to get the Datetime value from a row by having the X coordonate?

I need to implement Drag&Drop from a control to the phGantt(COM version under VB6) and the only one way I found is to use DragOver and DragDrop events. By having the Y value I found the needed row and tree item, how can I find the datetime value where something was droped from that line?

Answer

Once you have the correct x coordinate for the date scaler (you may or may not need to compensate for the grid width etc based on what you are doing ) you send this in to the function IphGantX3.PixelToDate(x:int):TDatetime

10557 : Open application on network share.

Question

On opening Gant chart using PTGantChart.ocx control on a network (client m/c), the page crashes giving an Object Not set to reference error and parent pages also crashes. Though the same code with data executes successfully on the server.

Answer

Although not entirely sure that this is your problem the policies for loading and executing applications in non full trust locations (the internet, or a network share) can be restricted by your network administrator. Maybe your administrator has restricted windows from loading unsigned ocx’s from partly trusted locations? You can sign the ocx’s with third party tools.

On the other hand, the ActiveX control must be registered on the client computer with regsvr32 to function, and if you register it on a network share it will get the network path in the registry. If your network path changes (sometimes X:\aaa and sometimes Y:\aaa) that could be an explanation.

10504 : What is the difference between the classes CphDataEntity_Tree and CphDataEntity_Tree2?

Question

I’m using phGantXControl.ocx

What is the difference between the classes CphDataEntity_Tree and CphDataEntity_Tree2?

I have a CphDataEntity_GantTime item and I want to access to grid rows. It seems that the only way to do this is to use the property GridRowIndex of the class CphDataEntity_Tree2, but I cannot get any CphDataEntity_Tree2 item from my CphDataEntity_GantTime item.

Answer

This is the naming convention when designing a new interface with more functionality: Ix = version one of the interface; Ix2 = version two of the interface.

So CphDataEntity_Tree2 is only a more competent version of

CphDataEntity_Tree.

You can type cast from a CphDataEntity_Tree to a CphDataEntity_Tree2 to access the extended functionality with QueryInterface

This is from the help file, the section called “Understanding interfaces”

Type casting

In VB6 you can do a interface type casting like this:

Dim tn As IphDataEntity_Tree2

  Set tn = theDataEntity.Row.TreeNode

The “theDataEntity.Row.TreeNode” returns a IphDataEntity_Tree but we want to use it as an IphDataEntity_Tree2 in order to reach newer functionality.

In Delphi you would do it like this

tn : IphDataEntity_Tree2;

begin

  tn := theDataEntity.Row.TreeNode As IphDataEntity_Tree2;

 

In VC++ you would do it like this:

CphDataEntity_Tree2  treenode;

       treenode=CphDataEntity_Tree2(theDataEntity.GetRow().GetTreeNode());

.

10522 : Dependencies between gantt items

Question

Can we create dependencies between gantt items using MS Project method by draying a line from predecessor to successor in the gantt chart?

Answer

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

Yes

Set the property IphGantX3.StickyMode=smDependency and the next click on a
time item will draw an outline of a link with IphGantX3.DefaultLinkColor and IphGantX3.DefaultLinkStyle.

To actually create the link object you implement the OnDependencyAction event:

Private Sub phGantX1_OnDependencyAction(ByVal theGant As phGantXControl.IphGantX3, ByVal theStartDataEntity As phGantXControl.IphDataEntity_GantTime2, ByVal theTargetDataEntity As phGantXControl.IphDataEntity_GantTime2)

    Dim aLink As IphDataEntity_Link
    Set aLink = theGant.AddLink
   
    aLink.LinkOwner = theStartDataEntity
    aLink.LinkedTo = theTargetDataEntity
    aLink.LinkStyle = tlsMSProject   

End Sub

 

 

10360 : phGantTimePackage Virtual load

Question

I am finding Virtual load difficult to use in my project, may be due to lack of knowledge regarding the working of phGantt Chart Virtual View. I am handling task management using the phGantt Chart. Following is the data structure that I have used for managing tasks internally.< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

Class CTask
{
      CString m_strTaskName;
      COleDateTime m_dtStartDate;
     
COleDateTime m_dtDueDate;
      
// …. More declarations goes here

      CTaskList   m_SubtaskList; // Sub nodes

};

 

Q1) How and when do I associate CTask* as UserVariant Reference for the nodes?

Q2) I tried using AddDataEntityTree() method for adding subnodes on the callback function? Can’t get it? An example would be appreciable?

 

Answer

I would associate the CTask instance with the TimeItem in the IphGantX3.OnVirtualLoadGrid event, put it in the pointer in the UserIntegerReference.
 
In the IphGantX3.OnVirtualLoadGrid you can add subnodes to the RootNode by calling: IphGantX3.AddDataEntityTree(theRootNode), but I think your problem is with getting the theRootNode corresponding to this virtually loaded row…
 
This is understandable but this what you need to know:
The sent in theRowIndex is the index of the root dataentity tree, so you can access it with IphGantX3.RootDataEntitiesTree(theRowIndex)
 
So you can add subnodes like this:
IphGantX3.AddDataEntityTree(IphGantX3.RootDataEntitiesTree(theRowIndex))
   
 

10552 : How do I to control the links with delphi

Question

How do I to control the links with the VCL version?

Answer

This is a code snippet showing how to enter the link create mode in Delphi. The link create mode (smDependency) allows the user to click one time item and drag out a link to another time item in order to create the depency link:

procedure TForm1.SpeedButtonLinkClick(Sender: TObject);
begin

  // Enter depenency create mode… Will stay in this mode until link created
  phGant1.StickyMode:=smDependency;
end;

procedure TForm1.phGant1DependencyAction(theFirst,
  theSecond: TphDataEntity_GantTime);
var
  aLink:TphDataEntity_Link;
begin

  // Leave the sticky mode
  phGant1.StickyMode:=smNone;

  aLink:=phGant1.AddLink;
  aLink.LinkOwner:=theFirst;
  aLink.LinkedTo:=theSecond;

  aLink.LinkStyle:=phGant1.DefaultLinkStyle;
  aLink.LinkColor:=phGant1.DefaultLinkColor;
  aLink.LinkPenWidth:=phGant1.DefaultLinkPenWidth;

end;