Home Image-Pro Automation (Macros, Apps, Reports)

CODE to COPY DATA TABLE as IMAGE (rather than as TEXT) . . .

2018-11-20-170131

I typed up a really pretty version of this question with code examples and everything and the FORUM seems to have eaten my homework.

This version is a bit more terse.

Is there CODE that will create an IMAGE of the DATA TABLE?

I think something like 
ThisApplication.Panels.Control("DataTable").DrawToBitmap
might do but I cannot find enough information on the Panels.Control and DrawToBitmap to figure this out.

I would like to get a copy of the DATA TABLE as PIXELS so I can paste them into the IMAGE WINDOW next to the IMAGE PIXELS.

Can this be done?

Thanks.

-- Matt


Comments

  • 2018-11-20-171605

    All --

    I occurred to me to me to search within the FORUM for the

        DrawToBitmap

    In doing so, I found the following code from NIKITA within a discussion.
        Public Sub GetDesignerImage
            For Each f As System.Windows.Forms.Form In System.Windows.Forms.Application.OpenForms
                GetDesignerControl(f)
            Next
        End Sub
    
        Private Sub GetDesignerControl(c As System.Windows.Forms.Control)
            If c IsNot Nothing AndAlso c.Visible Then
                If c.GetType.ToString = "DevComponents.AdvTree.AdvTree" Then
                    Dim b As New System.Drawing.Bitmap(c.Width, c.Height)
                    c.DrawToBitmap(b, New System.Drawing.Rectangle(0, 0, c.Width, c.Height))
                    b.Save("C:\" & Now.Ticks & ".bmp")
                End If
    
                For Each c2 As System.Windows.Forms.Control In c.Controls
                    GetDesignerControl(c2)
                Next
            End If
        End Sub

    When I run

        GetDesignerImage

    I get the following error.



    This error does not seem to be an IMPORT / REFERENCE ERROR.

    What is the best way to proceed?

    Thanks.

    -- Matt


  • Hi Matt,

    You were almost there, the main issue is to get the right panel name. The easiest way is to get it from Gadgets command.
    Here is the code
        Public Sub SaveTableScreenshot
            Dim panelName As String
            'be sure the table is visible
            With Measure.Measurements.Gadgets.DataTable(Nothing)
                .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
                .Run()
                'get panel name
                panelName =.PanelName
            End With
    
            SaveToBMP(ThisApplication.Panels.Control(panelName),"DataTable")
        End Sub
    
        Private Sub SaveToBMP(c As System.Windows.Forms.Control, caption As String)
            If c IsNot Nothing AndAlso c.Visible Then
                Dim b As New System.Drawing.Bitmap(c.Width, c.Height)
                c.DrawToBitmap(b, New System.Drawing.Rectangle(0, 0, c.Width, c.Height))
                Dim fn As String=ThisApplication.Path(mcPathType.mcptWritableImages) & caption & ".bmp"
                b.Save(fn)
            End If
        End Sub
    

    Yuri
  • 2018-11-29-1410

    Yuri --

    Thank you for working through this and responding.

    The customer is working with V1A version of the software now.

    I will try this CODE out ASAP and implement it when if his review requires any CODE modifications.

    Thanks again.

    -- Matt
Sign In or Register to comment.