WinForm可以直接使用控件面向对象方式,不需要利用open_window这样的方法去开辟窗口,如果用不了控件可以采取下面的面向对象代码:
- HalconDotNet.HSmartWindowControl hSmartWindow = new HalconDotNet.HSmartWindowControl();
- hSmartWindow.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
- hSmartWindow.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange;
- hSmartWindow.HDoubleClickToFitContent = true;
- hSmartWindow.HDrawingObjectsModifier = HalconDotNet.HSmartWindowControl.DrawingObjectsModifier.None;
- hSmartWindow.HImagePart = new System.Drawing.Rectangle(0, 0, 640, 480);
- hSmartWindow.HKeepAspectRatio = true;
- hSmartWindow.HMoveContent = true;
- hSmartWindow.HZoomContent = HalconDotNet.HSmartWindowControl.ZoomContent.WheelForwardZoomsIn;
- hSmartWindow.Location = new System.Drawing.Point(9, 266); //窗口产生的位置
- hSmartWindow.Margin = new System.Windows.Forms.Padding(0);
- hSmartWindow.Name = "hSmartWindowControl2"; //窗口的名称
- hSmartWindow.Size = new System.Drawing.Size(512, 512);
- hSmartWindow.TabIndex = 0;
- hSmartWindow.WindowSize = new System.Drawing.Size(512, 512);
- //记得最后添加图像窗口到窗口的控件集合中去
- this.Controls.Add(hSmartWindow);
复制代码 |