Highlighted
Absent Member.
Absent Member.
617 views

[archive] GANTT CHART or MS CHART

[Migrated content. Thread originally posted on 17 August 2007]

I am looking to incorporate some charts in our application. Is there anyone who would like to share a program that they have that produces a chart on the screen. I would appreciate looking at your code to get the syntax. Programming active x controls are not my strong points. Thanks.
0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] GANTT CHART or MS CHART

I am looking to incorporate some charts in our application. Is there anyone who would like to share a program that they have that produces a chart on the screen. I would appreciate looking at your code to get the syntax. Programming active x controls are not my strong points. Thanks.


Hope this helps, it uses the MS chart control.
This was the first thing I learned how to do after Gisle Forseth's advanced windows course in London and then its just been adapted further the more you're sort of forced into reading things. i.e the installing of the dll for example.
The program in question is a stock usage display and has a graph push button option which shows 3 years usage history of the product.
The code upon pressing the graph push button.
       Screen1-Pb-Graph-Ex-Cmd-Clicked.                 
           SET CONTROL-OK TO TRUE
           PERFORM CHECK-DLL
           IF CONTROL-NOT-OK
              PERFORM TRY-INSTALLING
              IF WS-RESULT = 0
                 PERFORM CHECK-DLL
                 IF CONTROL-OK
                    PERFORM REGISTER-DLL
                 ELSE
                    DISPLAY MESSAGE BOX
                 "The necessary control is not present on your machine"
                    EXIT PARAGRAPH
                 END-IF
              ELSE
                 DISPLAY MESSAGE BOX
                 "The necessary control is not present on your machine"
                 EXIT PARAGRAPH
              END-IF
           END-IF
           PERFORM Acu-Graph-Routine
           MOVE 4 TO ACCEPT-CONTROL
           MOVE 4 TO CONTROL-ID
           .



The rest of the code you might want to see.
If the control isn't present, we try to install it, even in thin client mode on a unix server we copy the dll to the client etc

      *
       CHECK-DLL.
           IF IS-REMOTE
              CALL "@[DISPLAY]:MSCHART.dll@WINAPI"
                 ON EXCEPTION
                    SET CONTROL-NOT-OK TO TRUE
                 NOT ON EXCEPTION
                    SET CONTROL-OK TO TRUE
                    CANCEL "@[DISPLAY]:MSCHART.dll"
              END-CALL
           ELSE
              CALL "MSCHART.dll@WINAPI"
                 ON EXCEPTION
                    SET CONTROL-NOT-OK TO TRUE
                 NOT ON EXCEPTION
                    SET CONTROL-OK TO TRUE
                    CANCEL "MSCHART.dll"
              END-CALL
           END-IF
           .
      *
       REGISTER-DLL.
           IF IS-REMOTE
              CALL "@[DISPLAY]:MSCHART.dll@WINAPI"
                 ON EXCEPTION
                    SET CONTROL-NOT-OK TO TRUE
                 NOT ON EXCEPTION
                    SET CONTROL-OK TO TRUE
                    CALL "@[DISPLAY]:DllRegisterServer" GIVING WS-STATUS
                    IF WS-STATUS = ZERO
                       SET CONTROL-OK TO TRUE
                    END-IF
                    CANCEL "@[DISPLAY]:MSCHART.dll"
              END-CALL
           ELSE
              CALL "MSCHART.dll@WINAPI"
                 ON EXCEPTION
                    SET CONTROL-NOT-OK TO TRUE
                 NOT ON EXCEPTION
                    SET CONTROL-OK TO TRUE
                    CALL "DllRegisterServer" GIVING WS-STATUS
                    IF WS-STATUS = ZERO
                       SET CONTROL-OK TO TRUE
                    END-IF
                    CANCEL "MSCHART.dll"
              END-CALL
           END-IF
           .
      *
       TRY-INSTALLING.
           IF IS-REMOTE
              CALL "@[DISPLAY]:KERNEL32.DLL@WINAPI"
                 ON EXCEPTION
                    EXIT PARAGRAPH
              END-CALL
              SET WS-SYS-DIR-SIZE TO SIZE OF WS-SYSTEM-DIRECTORY
              CALL "@[DISPLAY]:GetSystemDirectoryA" USING
                        BY REFERENCE WS-SYSTEM-DIRECTORY
                        BY REFERENCE WS-SYS-DIR-SIZE
                        GIVING WS-SYS-DIR-SIZE
              CANCEL "@[DISPLAY]:KERNEL32.dll"
           ELSE
              CALL "KERNEL32.DLL@WINAPI"
                 ON EXCEPTION
                    EXIT PARAGRAPH
              END-CALL
              SET WS-SYS-DIR-SIZE TO SIZE OF WS-SYSTEM-DIRECTORY
              CALL "GetSystemDirectoryA" USING
                        BY REFERENCE WS-SYSTEM-DIRECTORY
                        BY REFERENCE WS-SYS-DIR-SIZE
                        GIVING WS-SYS-DIR-SIZE
              CANCEL "KERNEL32.dll"
           END-IF
           ADD 1    TO WS-SYS-DIR-SIZE
           MOVE "\" TO WS-SYSTEM-DIRECTORY(WS-SYS-DIR-SIZE:1)
      *
      *Above routine calls windows api and gets actual system directory
      *Below routine copies the DLL to the system directory
      *
           MOVE SPACES TO WS-DESTINATION
           IF IS-REMOTE
              STRING "@[DISPLAY]:"       DELIMITED BY SIZE
                     WS-SYSTEM-DIRECTORY DELIMITED BY "  "
                     "MSCHART.dll"       DELIMITED BY SIZE
                     INTO WS-DESTINATION
              END-STRING
              IF OS-IS-UNIX
                 CALL "C$COPY" USING "/logic/add-ins/MSCHART.dll"
                                     WS-DESTINATION
                      GIVING WS-RESULT
              ELSE
                 CALL "C$COPY" USING "C:\LOGIC\ADD-INS\MSCHART.DLL"
                                     WS-DESTINATION
                      GIVING WS-RESULT
              END-IF
           ELSE
              STRING WS-SYSTEM-DIRECTORY DELIMITED BY "  "
                     "MSCHART.DLL"       DELIMITED BY SIZE
                     INTO WS-DESTINATION
              END-STRING
              CALL "C$COPY" USING "C:\LOGIC\ADD-INS\MSCHART.DLL"
                                  WS-DESTINATION
                   GIVING WS-RESULT
           END-IF
           .
      *
       Graph-Aft-Initdata.   
           MODIFY SCR-CHART, @DataGrid::RowLabelCount = 1
                             @DataGrid::ColumnCount = 3
                             @DataGrid::RowCount = 1
                             @ChartType = VtChChartType2dBar
           MODIFY SCR-CHART, @Row    = 1
                             @Column = 1
                             @Data   = WS-ISD-TOT(1)
                             @Row    = 1
                             @Column = 2
                             @Data   = WS-ISD-TOT(2)
                             @Row    = 1
                             @Column = 3
                             @Data   = WS-ISD-TOT(3)
           MODIFY SCR-CHART,
                           @DataGrid::ColumnLabel(1, 1, "This Year")
                           @DataGrid::ColumnLabel(2, 1, "Last Year")
                           @DataGrid::ColumnLabel(3, 1, "Previous Year")
                           @DataGrid::RowLabel(1, 1, S-ISM-DESC)
                           @ShowLegend 1
                           VISIBLE TRUE           
           .
      *
       PIE-CHART-PB-Ex-Cmd-Clicked.
           MODIFY PIE-CHART-PB, ENABLED FALSE
           MODIFY SCR-CHART, @ChartType = VtChChartType2dPie
           MODIFY SCR-CHART, Plot::SeriesCollection::Count()
                  GIVING WS-SLICE
           PERFORM UNTIL WS-SLICE = 0
              INQUIRE SCR-CHART
                Plot::SeriesCollection::Item(WS-SLICE)::DataPoints IN
                HDATAPOINTS
              USE HDATAPOINTS Item(-1)
                 MODIFY ^DataPointLabel::LocationType =
                        VtChLabelLocationTypeOutside
                        ^DataPointLabel::Component =
                        VtChLabelComponentPercent
                        ^DataPointLabel::PercentFormat = "0%"
                        ^DataPointLabel::VtFont::Size = 14
              END-USE
              SUBTRACT 1 FROM WS-SLICE
           END-PERFORM     
           .


The graph screen has another push button to switch from a bar to pie chart.
I could'nt figure out how to switch it back to bar chart again properly so just left it so that the user has to close the screen and pick it again.

I don't know if Gisle is doing another of these courses, but if he is then I'd definately book yourself a place.
But beware, its pretty head wrecking at first.

Shaun
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] GANTT CHART or MS CHART

Thanks for sharing your code.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] GANTT CHART or MS CHART

How to you print a chart once it has been created? Is MSChart for display only?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] GANTT CHART or MS CHART

I wasn't interested in the Charts, But I was looking at a way to Auto install dll's if they were missing on the client machine from the server via thin client. Thanks for sharing your logic I really appreciate it.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] GANTT CHART or MS CHART

Some chart controls may have the capability to print themselves, however, in order to do so, you need to provide them with the device context to print on. In ACUCOBOL-GT you can achieve this by using the global variable H-ACU-SPOOLER-DC.
If the control really has no print method, a very viable alternative is to make screen shot of it. The W$BITMAP library routine has a subfunction to take a handle of a control and create a bitmap file of it. Then you can reload this bitmap file with W$BITMAP and print it.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.