10031 : I have the COM version of the phGantTimePackage. Want to Upgrade to .NET version. So I still have to pay full price ???

Question

I have the COM version of the phGantTimePackage.
Want to Upgrade to .NET version. So I still have to pay full price ???

Answer

No, we still offer 50% off for phGantTimePackage users.

In the online store choose GTP.NET and then “1 Developer Upgrade License from Gantt Time Package ActiveX / VCL edition”. You will need to communicate your old license details for this to work… 

 

10020 : Move a GanttTime within a list

Question

We are using phGantTimePackage COM Ver. 3.5.4 using VC+ 6.
 
Even after reading the documentation thoroughly, I am unclear about moving tree nodes.
I figured how to move a tree node into an other like this:
CphDataEntity_Tree2 m_theSourceTree is the tree item where drag started.

CphDataEntity_Tree2 m_theDestTree is the tree item where drop stopped.


m_theSourceTree.ChangeOwner(m_theDestTree.SubDataList(), m_theDestTree.SubDataList().Count());
 
I found out how to put a tree item at the end of the list:
  CphDataList_Tree RootTree;
  RootTree = m_ganttchart.GetRootDataEntitiesTree();
 
  CphDataEntity_Tree2 SoonToBeOldOwner;
  SoonToBeOldOwner = m_theSourceTree.GetParent();
  CphDataList_Tree OwnDatalist = SoonToBeOldOwner.SubDataList();
 
  m_theSourceTree.ChangeOwner(RootTree, RootTree.Count());
 
Now, I am wondering how I move a treeitem within the tree. Lets say I want to move a tree item from row 12
to row 4 like Yapp does. My ultimate plan is that, after the drop, I will get a popup menu asking the user where they want to move the source tree item; above, into, under, the node dropped to.
 
As demonstrated above, I know how to handle the into case. However, I have no clue how to implement the ‘above’ and ‘under’ cases.

Resolution

You are correct in your description on how to acheive these operations, the only thing you have not found is the IphDataList2.Move(oldind,newind) operation.

If you have a IphDataEntity_Tree and want to move it within its list;   ((typecast to IphDataList2) aTreeNode.OwningDataList).Move(currPos,NewPos);

 

 

 

10019 : How to display the start and end time of a time object while it is being dragged

Question

Is there currently a way to display the start and end time of a time object while it is being dragged?

Resolution

Yes, you use the OnHintInfo event and use the arguments “theStart” and “theLength”, you can also use the IphGantX3.GetMouseMoveMode to find out what operation it is that is being applied.

private void axphGantX1_OnHintInfo(object sender, AxphGantXControl.IphGantXEvents_OnHintInfoEvent e)
{
  if (e.theStart.ToOADate()>0)
  {
    labelHint.Text=”Starts”+e.theStart.ToString()+” and This long:”+e.theLength.ToString();
  }
  else
  {
    labelHint.Text=”nada”;
  }
}

10018 : How to get the TreeNode from a TimeItem

Question

In our program the user selects a time item.  When I then wants to edit a item another window will be show with all the details of the item. He users makes some changes and the data will be stored. The ghant will then reload automaticly. Pretty straightforward so far. < ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I would like to automaticly return to the row on which the time item is that was edited. I know I can go to a certain row using : 

Dim aTreeItem As phGantXControl.IphDataEntity_Tree2

Give aTreeItem a destination and then use : 

phGantX1.SetTopItemTree aTreeItem

I already use this in our search function. In my click function I have got (for some other thing in the program) :

 Private Sub phGantX1_OnClickGantArea(ByVal theGant As phGantXControl.IphGantX, ByVal theDataEntity As phGantXControl.IphDataEntity_GantTime)

    On Error Resume Next

    If (Not phGantX1.ActiveDataEntity Is Nothing) Then

        PlanningId = theDataEntity.UserIntegerReference

    End If

End Sub

 

But how can I now set the variable aTreeItem to the correct row/treenode?

 

Resolution

If you have a time item and need its owning tree node you can do like this:

theTimeItem As phGantXControl.IphDataEntity_GantTime2

theTimeItem=theDataEntity ‘ Make sure we use the IphDataEntity_GantTime2 interface

theRow as IphGantRow3

theRow=theTimeItem.Row

theRow.TreeNode ‘ we have the treenode

The pitfall of this exercise is the fact that you sometimes need to cast to a newer interface (same name but a higher number postfix) that holds more information; the IphDataEntity.Row returns a IphGantRow, but we need a IphGantRow3 that has the row property. In VB we cast by assigning to a variable of the desired type. In c# we would use the “As” operator

 

10016 : Can I change the week numbers

Question

Is it possible to have the phSchema display weeks like SQL server. ie Week of year, not necessarily 7 days from a particular day. In that case, the last week of last year (2004) would have 5 days instead of 7, assuming that the first day is monday. We need this because that is how we worked out the weeks in the back end, and we need to display it like that.

Resolution

The phGant and phSchema display weeks as specified by the Julian-day-number-algorithm. You can override all texts that the components write to the datescaler by implementing OnScalerStringLong and OnScalerStringShort. These two events has reference arguments with the suggested string, they also have arguments with the date and resolution that this string represent.

So to get the week-number in a definition where week 1 always starts at the first of January, you would count the days from to today and modulus 7; (Today- (05-01-01)) mod 7

This gives you a zero based week number; add 1 and you have your week number…

You only want to change the output text when week-numbers are shown and you check this by controlling the theStep argument of the events. When weeks are show theStep equals 7 (7 days in a week).

So put this in your OnScalerStringShort and OnScalerStringLong implementation;

If theStep=7 then

  theResult=’xw’+IntToStr(((Now-firstDayOfYear) mod 7)+1)

 

10007 : Multi page print

This sample uses VB6 code to show how to call the PrintToHdc method and also react to OnPrintToHdcNewPage event that will allow you to divide your print over as pages that are needed. OnPrintToHdcNewPage will also help you to skip pages and only render a page with a certain page number.

 

Private Sub CommandPrint_Click()
    Dim lngWidthReturned As Long
    Dim lngHeightReturned As Long
    Dim dblXscale As Double
    Dim lngTitleHeight As Long
    Dim lngPicWidth As Long
   
    gUsingMultiPagePrint = True
   
    With phGantX1
        dblXscale = 3.5
    
    
        lngPicWidth = picPreview.Width \ Screen.TwipsPerPixelX
       
        Printer.Print “Anything really”  ‘ must init printer somehow, ideal is to call StartDoc, but print will also suffice
        Call .PrintToHdc(Printer.hDC, 1, lngTitleHeight, dblXscale, dblXscale, .TreeWidth, _
                            .TopItemTree, -1, False, .Start, .Stop, .GetScaleLen, .ScalerHeight, _
                            lngWidthReturned, lngHeightReturned)
          
    End With
    Printer.EndDoc
   

End Sub

Private Sub phGantX1_OnPrintToHdcNewPage(ByVal theGant As phGantXControl.IphGantX3, ByVal aPageNo As Long, aPageHeight As Long, aPageWidth As Long, goahead As Boolean, render As Boolean)
    If gUsingMultiPagePrint Then
        If aPageNo > 1 Then
            Printer.NewPage
        End If
        aPageHeight = 1000 ‘pixels, you will probably want to find out the paper size and use it here
        aPageWidth = 1000 ‘pixels
        goahead = True   ‘ true, continue , false will end this print-run
        render = True    ‘ true=this page will be drawn, false=this page will not be drawn (good for print of page x)
        
    Else
        aPageHeight = -1 ‘no limit
        aPageWidth = -1 ‘no limit
        goahead = True
        render = True
    End If
   
End Sub

————————————–

We got a question on how to go about adapting the print scaling in runtime so that you can use as much of the paper as possible

This is the way I did it when having more or less the same problem, my problem was only the grid but tweaking this approach you can use it for the Gantt:

    private void CustDocPrintDoc_PrintPage(object sender, PrintPageEventArgs e)
    {
          
      Rectangle r=new Rectangle(e.MarginBounds.Location,e.MarginBounds.Size);
      
      // here is check if my columns width are larger that the paper (or preview) width
      float
neededscaling=((float)e.MarginBounds.Width)/((float)Math.Max(3000,grid.Columns.SumWidth()));       if (neededscaling<1 && neededscaling>0) { // Then I scale it... e.Graphics.ScaleTransform(neededscaling,neededscaling); // ...and since everything got smaller, I can print a bigger Rectangle...
r= new Rectangle((int)(r.X/neededscaling),(int)(r.Y/neededscaling),(int)(r.Width/neededscaling),(int)(r.Height/neededscaling)); }
grid.PrintPage(e.Graphics,r,ref morep); e.HasMorePages=morep; }

 

10006 : Expanding tree

Question

 I want to restrict the user from seeing the tree item contents… if user tries to click on parent tree item .. [+] the child tree item should not be shown.. that is what I wish to restrict.< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Answer

Implement IphGantX3.OnTreeExpand and set the Allow parameter to false. It will do the trick.

 

10003 : VC++ 2003 WM_GETDLGCODE, Endless loop

Question

We are trying to integrate this control in one of our product but we have a serious problem. When the scrollbar of the grid (of the ActievX) is hit the application is entering in an endless loop, by sending continuesly the WM_GETDLGCODE to the control.

The working environment is VC++ 2003. We have a dialog box and a custom control on it. The custom control has as child the ActiveX control. The custom control is implemented in a DLL.

If you want I can send you a test application, where you can recontruct easily this problem.

Answer

This only happen for VC++ MFC apps. We fixed the problem in a pre-release that was verified by the client. It will be available for download as a service release.

11547 : Gantt_ASP change the grid columns sort icon

Question

Hello Support, I am using the PlexityHide.Gtp version 3.1.9.8. I want to change the grid columns sort icon. Is it possible to change the sort icon? If yes how to change it (if possible plz provide the code), if no then is there any work around to show some other icon over it because current sort icon is not looking good, the icon is not easily recognized by end user, it looks like digit 7. Thanks in advance for your help.

Answer

In Gantt_ASP you can implement the OnGetResource event.

When called with PlexityHide.GTP.WEB.sort_ascending.gif, PlexityHide.GTP.WEB.sort_descending.gif or PlexityHide.GTP.WEB.sort_empty.gif, supply your own valid url to an image…

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

 

11546 : Gantt_ASP, adding hyperlink in the grid

Question

I want to add a hyperlink “Delete” for each row in the grid

Answer

 

Add a extra column that has nothing in the DataSourceColumn:

        Gantt_ASP1.Gantt.Grid.Columns.AddNew(PlexityHide.GTP.CellType.SingleText);
        Gantt_ASP1.Gantt.Grid.Columns[1].DataSourceColumn = “”;

Then when the row is initiated, inject your callback link:

 

    void Grid_OnNodeInserted(Grid aGrid, NodeEventArgs e)
    {
        // For each new node we set up databind for subnodes…
        e.GridNode.SubNodes_DataSource = (e.GridNode.ListItemWhenDataBound() as DataRowView).CreateChildView(“subnodes”);

        string postbackref = “DELETE:” + Gantt_ASP1.GridNodeKey(e.GridNode.GetCell(1).GridNode);
        string deletecontent = “<a href=\”javascript:” + Page.ClientScript.GetPostBackEventReference(this, postbackref) + “\”>Delete</a>”;
        e.GridNode.GetCell(1).Content.Value = deletecontent;

        // and for time items
        GanttRow gr = Gantt.GanttRowFromGridNode(e.GridNode);
        gr.IncreaseRowHeightOnCollision = true;
        gr.IncreaseRow_SuggestedHeightPerItem = 20;
        gr.Layers[0].TimeItemLayout = “spacy”;
        gr.Layers[0].NameInDS_Identity = “id”;
        gr.Layers[0].NameInDS_Start = “start”;
        gr.Layers[0].NameInDS_Stop = “stop”;
        gr.Layers[0].DataSource = (e.GridNode.ListItemWhenDataBound() as DataRowView).CreateChildView(“timeitems”);
    }

Here I gave it a PostBack to the page (Page.ClientScript.GetPostBackEventReference(this…  )
So we need to make the page a IPostBackEventHandler
Just add IPostBackEventHandler behind the superclass Page:

public partial class _Default : System.Web.UI.Page, IPostBackEventHandler

Right click the IPostBackEventHandler and choose Implement interface:

Implement the handling code:

    private bool _deferActualDeleteUntilViewStateIsFullyApplied;
    private string _idToDelete;
    #region IPostBackEventHandler Members

    public void RaisePostBackEvent(string eventArgument)
    {
        string[] parts=eventArgument.Split(‘:’);
        if (parts.Length > 1)
        {
            if (parts[0] == “DELETE”)
            {
                _deferActualDeleteUntilViewStateIsFullyApplied = true;
                _idToDelete = parts[1];
            }
        }
    }

    #endregion

We do not want to delete directly, since the GridNodes are not sorted yet…
Instead we delete in the OnClientSideChangesApplied event, if applicable:

    protected void Gantt_ASP1_OnClientSideChangesApplied(object sender, EventArgs e)
    {
        if (_deferActualDeleteUntilViewStateIsFullyApplied)
        {
            GridNode gn_todelete = Gantt_ASP1.GridNodeFromKey(_idToDelete);
            if (gn_todelete != null && gn_todelete.ListItemWhenDataBound() != null)
            {

                (gn_todelete.ListItemWhenDataBound() as DataRowView).Delete();
            }
        }

     // Save the changes maybe…

    }