2

Is there any way to initialize a HalconWindow or a HSmartWindowControlWPF in C#? I am having multiple HSmartWindowControlWPFs in a TabView but only those that were visible before are updated. So if I am trying to put an HImage in all HalconWindows, without choosing another Tab than the default before, only the default Tab gets updated, all other HalconWindows stay black. But if they were once selected they are updated. Is there any way to create this behaviour automatically?

Monocito
  • 117
  • 1
  • 12

1 Answers1

1

The key is to index through the tabs at initialization so that they initialize the controls.

    private void TabbedHalconApp_Loaded(Object sender, RoutedEventArgs e)
    {
        TabControl1.BeginInit();
        for (int index = 0; index < this.TabControl1.Items.Count; index++)
        {
            this.TabControl1.SelectedIndex = index;
            this.TabControl1.UpdateLayout();
        }
        // Reset to first tab
        this.TabControl1.SelectedIndex = 0;
        TabControl1.EndInit();
    }

Then you can load the image to the Halcon window. Here is how you might do this when the form is loaded.

    private void HWindow2_Loaded(Object sender, EventArgs e)
    {
        (sender as HSmartWindowControlWPF).HalconWindow.DispImage(myTestImage);
    }

    private void HWindow1_Loaded(Object sender, RoutedEventArgs e)
    {
        (sender as HSmartWindowControlWPF).HalconWindow.DispImage(myTestImage);
    }
RtiBobV
  • 21
  • 3