OPC Studio User's Guide and Reference
OpcServerDialog Class
Members  Example 



OpcLabs.EasyOpcForms Assembly > OpcLabs.EasyOpc.Forms.Browsing Namespace : OpcServerDialog Class
Displays a dialog box from which the user can select an OPC "Classic" server.
Object Model
OpcServerDialog ClassEasyAEClientSelector ClassEasyDAClientSelector ClassServerElement Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcServerDialog)>
<ComVisibleAttribute(True)>
<GuidAttribute("DF678162-A326-4BDF-9427-914A44C51FD2")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<DesignerCategoryAttribute("Component")>
Public NotInheritable Class OpcServerDialog 
   Inherits OpcDialog
   Implements OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcDialog, OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcServerDialog, System.ComponentModel.IComponent, System.IDisposable 
'Usage
 
Dim instance As OpcServerDialog
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcServerDialog)]
[ComVisible(true)]
[Guid("DF678162-A326-4BDF-9427-914A44C51FD2")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[DesignerCategory("Component")]
public sealed class OpcServerDialog : OpcDialog, OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcDialog, OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcServerDialog, System.ComponentModel.IComponent, System.IDisposable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcServerDialog)]
[ComVisible(true)]
[Guid("DF678162-A326-4BDF-9427-914A44C51FD2")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[DesignerCategory("Component")]
public ref class OpcServerDialog sealed : public OpcDialog, OpcLabs.BaseLib.Forms.ComTypes._FormCommonDialog, OpcLabs.BaseLib.Forms.ComTypes._SizableCommonDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcDialog, OpcLabs.EasyOpc.Forms.Browsing.ComTypes._OpcServerDialog, System.ComponentModel.IComponent, System.IDisposable  
Remarks

OpcServerDialog is a modal dialog box; therefore, when shown, it blocks the rest of the application until the user has chosen an OPC server. When a dialog box is displayed modally, no input (keyboard or mouse click) can occur except to objects on the dialog box. The program must hide or close the dialog box (usually in response to some user action) before input to the calling program can occur.

 

General

Icon :

If you do not know upfront which OPC server to connect to, and do not have this information from any other source, your application will need to allow the user select the OPC server(s) to work with. The OPC Server Dialog (OpcServerDialog class) allows the user to select the OPC server interactively from the list of OPC Data Access servers installed on a particular machine.

Here is an example of OPC Server dialog in action:

The ServerFamilies property of the dialog determines whether OPC Data Access servers, OPC Alarms&Events servers, other servers, or a combination of them will be browsed. By default, all server families are browsed. In order to limit the browsing to OPC Data Access servers only, set the ServerFamilies property to the OpcDataAccess enumeration member.

To run the dialog, set the Location property to the name of the computer that is to be browsed, and call the ShowDialog method. If the result is equal to DialogResult.OK, the user has selected the OPC Data Access server, and information about it can be retrieved from the ServerElement property.

.NET

// This example shows how to let the user browse for an OPC "Classic" server.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System.Windows.Forms;
using OpcLabs.EasyOpc.Forms.Browsing;

namespace FormsDocExamples._OpcServerDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var serverDialog = new OpcServerDialog();
            //serverDialog.Location = "";

            DialogResult dialogResult = serverDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, serverDialog.ServerElement);
        }
    }
}
# This example shows how to let the user browse for an OPC "Classic" server.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcForms.dll"

$serverDialog = New-Object OpcLabs.EasyOpc.Forms.Browsing.OpcServerDialog
#$serverDialog.Location = ""

$dialogResult = $serverDialog.ShowDialog()
if ($dialogResult -ne [System.Windows.Forms.DialogResult]::OK) {
    return
}

# Display results
Write-Host $serverDialog.ServerElement
# This example shows how to let the user browse for an OPC "Classic" server.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.Forms.Browsing import *


serverDialog = OpcServerDialog()
#serverDialog.Location = ''

dialogResult = serverDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print('ServerElement: ', serverDialog.ServerElement, sep='')
' This example shows how to let the user browse for an OPC "Classic" server.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.Forms.Browsing

Namespace FormsDocExamples._OpcServerDialog
    Friend Class ShowDialog
        Shared Sub Main1(owner As IWin32Window)
            Dim serverDialog = New OpcServerDialog()
            'serverDialog.Location = "" 

            Dim dialogResult As DialogResult = serverDialog.ShowDialog(owner)
            If dialogResult <> DialogResult.OK Then
                Return
            End If

            ' Display results
            MessageBox.Show(owner, serverDialog.ServerElement)
        End Sub
    End Class
End Namespace

COM

// This example shows how to let the user browse for an OPC "Classic" server.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

class procedure ShowDialog.Main;
var
  ServerDialog: OpcLabs_EasyOpcForms_TLB._OpcServerDialog;
begin
  // Instantiate the dialog object
  ServerDialog := CoOpcServerDialog.Create;

  ServerDialog.ShowDialog(nil);

  // Display results
  WriteLn(ServerDialog.ServerElement.ToString);
end;
Rem This example shows how to let the user browse for an OPC "Classic" server.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    ' Instantiate the dialog object
    Dim serverDialog As New OpcServerDialog
    Dim DialogResult
    DialogResult = serverDialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    OutputText = OutputText & serverDialog.ServerElement & vbCrLf
End Sub
Rem This example shows how to let the user browse for an OPC "Classic" server.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Const DialogResult_OK = 1

Dim ServerDialog: Set ServerDialog = CreateObject("OpcLabs.EasyOpc.Forms.Browsing.OpcServerDialog")
'ServerDialog.Location = ""
Dim dialogResult: dialogResult = ServerDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo ServerDialog.ServerElement

 

Advanced

If you want to change the parameters of the client objects the component uses to perform its OPC operations, you can use the DAClientSelector Property or the AEClientSelector Property.

 

Icon:

The OPC Server Dialog (OpcServerDialog class) allows the user to select the OPC server interactively from the list of OPC “Classic” servers installed on a particular machine.

To select from OPC Alarms&Events servers, you use the same dialog as with OPC Data Access servers – for details on that dialog, see OPC Server Dialog under “User Interface for OPC-DA”. The only difference is that before running the dialog, you need to make sure that its ServerFamilies property is set so that it includes (or only contains) the OpcAlarmsAndEvents enumeration member.

 

Example

.NET

COM

// This example shows how to let the user browse for an OPC "Classic" server.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System.Windows.Forms;
using OpcLabs.EasyOpc.Forms.Browsing;

namespace FormsDocExamples._OpcServerDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var serverDialog = new OpcServerDialog();
            //serverDialog.Location = "";

            DialogResult dialogResult = serverDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, serverDialog.ServerElement);
        }
    }
}
# This example shows how to let the user browse for an OPC "Classic" server.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcForms.dll"

$serverDialog = New-Object OpcLabs.EasyOpc.Forms.Browsing.OpcServerDialog
#$serverDialog.Location = ""

$dialogResult = $serverDialog.ShowDialog()
if ($dialogResult -ne [System.Windows.Forms.DialogResult]::OK) {
    return
}

# Display results
Write-Host $serverDialog.ServerElement
# This example shows how to let the user browse for an OPC "Classic" server.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.Forms.Browsing import *


serverDialog = OpcServerDialog()
#serverDialog.Location = ''

dialogResult = serverDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print('ServerElement: ', serverDialog.ServerElement, sep='')
' This example shows how to let the user browse for an OPC "Classic" server.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.Forms.Browsing

Namespace FormsDocExamples._OpcServerDialog
    Friend Class ShowDialog
        Shared Sub Main1(owner As IWin32Window)
            Dim serverDialog = New OpcServerDialog()
            'serverDialog.Location = "" 

            Dim dialogResult As DialogResult = serverDialog.ShowDialog(owner)
            If dialogResult <> DialogResult.OK Then
                Return
            End If

            ' Display results
            MessageBox.Show(owner, serverDialog.ServerElement)
        End Sub
    End Class
End Namespace
// This example shows how to let the user browse for an OPC "Classic" server.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

class procedure ShowDialog.Main;
var
  ServerDialog: OpcLabs_EasyOpcForms_TLB._OpcServerDialog;
begin
  // Instantiate the dialog object
  ServerDialog := CoOpcServerDialog.Create;

  ServerDialog.ShowDialog(nil);

  // Display results
  WriteLn(ServerDialog.ServerElement.ToString);
end;
Rem This example shows how to let the user browse for an OPC "Classic" server.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    ' Instantiate the dialog object
    Dim serverDialog As New OpcServerDialog
    Dim DialogResult
    DialogResult = serverDialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    OutputText = OutputText & serverDialog.ServerElement & vbCrLf
End Sub
Rem This example shows how to let the user browse for an OPC "Classic" server.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Const DialogResult_OK = 1

Dim ServerDialog: Set ServerDialog = CreateObject("OpcLabs.EasyOpc.Forms.Browsing.OpcServerDialog")
'ServerDialog.Location = ""
Dim dialogResult: dialogResult = ServerDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo ServerDialog.ServerElement
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.CommonDialog
            OpcLabs.BaseLib.Forms.ConcreteCommonDialog
               OpcLabs.BaseLib.Forms.FormCommonDialog
                  OpcLabs.BaseLib.Forms.SizableCommonDialog
                     OpcLabs.EasyOpc.Forms.Browsing.OpcDialog
                        OpcLabs.EasyOpc.Forms.Browsing.OpcServerDialog

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also