AdvancedHMI Software

General Category => Support Questions => Topic started by: zach_a_ary on August 02, 2023, 02:42:29 AM

Title: Print Current Screen/Form
Post by: zach_a_ary on August 02, 2023, 02:42:29 AM
Is there anyway to print current form of AdvancedHMI I am on? One of my forms has a bunch of production data on it. I would like to add a print button beside it. I see a few options under
Title: Re: Print Current Screen/Form
Post by: dmroeder on August 02, 2023, 11:20:40 AM
Is there anyway to print current form of AdvancedHMI I am on? One of my forms has a bunch of production data on it. I would like to add a print button beside it. I see a few options under

One method that comes to mind is to screenshot the form and save an image.  Haven't tried this myself:
https://stackoverflow.com/questions/37825662/how-to-save-the-whole-windows-form-as-image-vb-net

Another method might be to take all of the values from the objects on your form and save them to a CSV file:
https://stackoverflow.com/questions/32985154/creating-excel-and-csv-files-in-vb-net
Title: Re: Print Current Screen/Form
Post by: zach_a_ary on August 02, 2023, 10:44:54 PM
Thank you for your help. With that info i was able to find what i needed. Im not real savvy with c# or vb but this is what i ended up with. It works fine for what i need
Title: Re: Print Current Screen/Form
Post by: zach_a_ary on August 02, 2023, 10:48:33 PM
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Dim frm = Form.ActiveForm

    Using bmp = New Bitmap(frm.Width, frm.Height)
        frm.DrawToBitmap(bmp, New Rectangle(0, 0, bmp.Width, bmp.Height))

        bmp.Save("c:\temp\screenshot.png")
   
 End Using
End Sub
Title: Re: Print Current Screen/Form
Post by: dmroeder on August 03, 2023, 09:46:57 AM
Nice.  I don't do a lot of VB.NET these days so I have to google most things :)