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?
Asked
Active
Viewed 694 times
2

Monocito
- 117
- 1
- 12
-
Could you add code sample please? – Vladimir Perković Oct 23 '19 at 14:01
1 Answers
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