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.

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… 

 

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).

 

 

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);

 

 

 

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

 

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”;
  }
}

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.