08-11-2008 01:05 AM
Solved! Go to Solution.
08-18-2008 09:43 AM - edited 08-18-2008 09:48 AM
Hi Bongchan,
Please refer to the attached images. You have to use the .NET functions almost like you would in Visual Basic/C#. Thus, the program is structured like so:
1. Create an instance of the System.Windows.Forms.Form class
2. Register the event Form_Paint that will invoke the callback VI
3. Create a graphics object from the PaintEventArgs passed into the callback VI
4. Create an image object that loads the picture file
5. Call the graphic object's method DrawImage using the image object
Here is the corresponding C# code:
name GDI_Test
{
// Create an instance of the System.Windows.Forms.Form class
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Register the event Form_Paint that will invoke the callback [Function]
private void Form1_Paint(object sender, PaintEventArgs e)
{
// Create a graphics object from the PaintEventArgs passed into the callback VI
Graphics g = e.Graphics;
// Create an image object that loads the picture file
Image test = Image.FromFile("C:\\test.png" );
// Call the graphic object's method DrawImage using the image object
g.DrawImage(test, 0, 0);
}
}
}
Steps 1 - 2:
Automatically create the callback VI by right-clicking on the VI Ref and selecting "Create Callback VI":
Steps 3 - 5:
08-18-2008 09:50 AM
10-08-2009 03:46 PM
How do I do step 1 - 2?
VI, Block Diagram, Functions, Connectivity, .NET, Register Event Callback placed. Members are Event, VI Ref, and User Parameter. Selecting Event says "No Events". If I open a LabVIEW example (e.g. NET Event Callback for Calendar Control.vi) I am able to disconnect all wires from it. select Event, and get a list from which I can pick Paint. Then I can drag it to my VI.
Similarly, I select VI Ref and and Create Callback VI is grey (disabled).
10-08-2009 04:18 PM
After creating the VIs as shown the caller runs but the image is not displayed. A break point in the callback is not triggered. What is the LabVIEW code that corresponds to the following C# code?
// Create an image object...
Image test = ...
10-08-2009 04:48 PM
10-08-2009 05:00 PM
To start from a new Reg Event Callback, you connect the reference from the Form .NET constructor into the Event terminal of the Reg Event Callback.
Regards,
Peter K.
04-19-2018 01:32 PM
I couldn't find the Reg Event Callback for a while either, but turns out it's just built in to LabView. It is located in the .NET Palette, or you can just Ctrl+Space and search "Register Event Callback"