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



OpcLabs.BaseLibForms Assembly > OpcLabs.BaseLib.Forms.Browsing.Specialized Namespace : ComputerBrowserDialog Class
Displays a dialog box from which the user can select a computer.
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.BaseLib.Forms.Browsing.Specialized.ComTypes._ComputerBrowserDialog)>
<ComVisibleAttribute(True)>
<GuidAttribute("E33FFD82-3956-4642-8C3B-EC04B9E297B6")>
<DesignerCategoryAttribute("Component")>
<SerializableAttribute()>
Public NotInheritable Class ComputerBrowserDialog 
   Inherits OpcLabs.BaseLib.Forms.ConcreteCommonDialog
   Implements OpcLabs.BaseLib.Forms.Browsing.Specialized.ComTypes._ComputerBrowserDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, System.ComponentModel.IComponent, System.IDisposable 
'Usage
 
Dim instance As ComputerBrowserDialog
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.BaseLib.Forms.Browsing.Specialized.ComTypes._ComputerBrowserDialog)]
[ComVisible(true)]
[Guid("E33FFD82-3956-4642-8C3B-EC04B9E297B6")]
[DesignerCategory("Component")]
[Serializable()]
public sealed class ComputerBrowserDialog : OpcLabs.BaseLib.Forms.ConcreteCommonDialog, OpcLabs.BaseLib.Forms.Browsing.Specialized.ComTypes._ComputerBrowserDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, System.ComponentModel.IComponent, System.IDisposable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.BaseLib.Forms.Browsing.Specialized.ComTypes._ComputerBrowserDialog)]
[ComVisible(true)]
[Guid("E33FFD82-3956-4642-8C3B-EC04B9E297B6")]
[DesignerCategory("Component")]
[Serializable()]
public ref class ComputerBrowserDialog sealed : public OpcLabs.BaseLib.Forms.ConcreteCommonDialog, OpcLabs.BaseLib.Forms.Browsing.Specialized.ComTypes._ComputerBrowserDialog, OpcLabs.BaseLib.Licensing.ILicensingContextHolder, System.ComponentModel.IComponent, System.IDisposable  
Remarks

ComputerBrowserDialog is a modal dialog box; therefore, when shown, it blocks the rest of the application until the user has chosen a computer. 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.

Icon: 

OPC servers are usually deployed on the network, and accessed via DCOM. In order to let the user select the remote computer where the OPC server resides, you can use the ComputerBrowserDialog object.

Call the ShowDialog method, and if the result is equal to  DialogResult.OK, the user has selected the computer, and its name can be retrieved from the SelectedName property.

.NET

// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System.Windows.Forms;
using OpcLabs.BaseLib.Forms.Browsing.Specialized;

namespace UAFormsDocExamples._ComputerBrowserDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var computerBrowserDialog = new ComputerBrowserDialog();

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

            // Display results
            MessageBox.Show(owner, computerBrowserDialog.SelectedName);
        }
    }
}
# This example shows how to let the user browse for computers on the network.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.

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

$computerBrowserDialog = New-Object OpcLabs.BaseLib.Forms.Browsing.Specialized.ComputerBrowserDialog

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

# Display results
Write-Host $computerBrowserDialog.SelectedName
' This example shows how to let the user browse for computers on the network.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.BaseLib.Forms.Browsing.Specialized

Namespace UAFormsDocExamples._ComputerBrowserDialog
    Friend Class ShowDialog
        Shared Sub Main1(owner As IWin32Window)
            Dim computerBrowserDialog = New ComputerBrowserDialog()

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

            ' Display results
            MessageBox.Show(owner, computerBrowserDialog.SelectedName)
        End Sub
    End Class
End Namespace

COM

// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _ComputerBrowserDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _ComputerBrowserDialogPtr DialogPtr(__uuidof(ComputerBrowserDialog));

            // 
            DialogResult dialogResult = DialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);
            
            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _tprintf(_T("%s\n"), (LPCTSTR)CW2CT(DialogPtr->SelectedName));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ShowDialog.Main;
var
  Dialog: ComputerBrowserDialog;
begin
  // Instantiate the dialog object
  Dialog := CoComputerBrowserDialog.Create;

  Dialog.ShowDialog(nil);
  // IMPROVE: check the dialog result

  WriteLn(Dialog.SelectedName);
end;
// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ShowDialog.Main;
var
  ComputerBrowserDialog: OpcLabs_BaseLibForms_TLB._ComputerBrowserDialog;
  DialogResult: System_Windows_Forms_TLB.DialogResult;
begin
  // Instantiate the dialog object
  ComputerBrowserDialog := CoComputerBrowserDialog.Create;

  DialogResult := ComputerBrowserDialog.ShowDialog(nil);
  WriteLn(DialogResult);

  if DialogResult <> DialogResult_OK then
    Exit;

  // Display results
  WriteLn(ComputerBrowserDialog.SelectedName);
end;
// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

$Dialog = new COM("OpcLabs.BaseLib.Forms.Browsing.Specialized.ComputerBrowserDialog");
printf("%d\n", $Dialog->ShowDialog);

// Display results
printf("%s\n", $Dialog->SelectedName);
# This example shows how to let the user browse for computers on the network.
#
# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
import win32com.client

dialog = win32com.client.Dispatch('OpcLabs.BaseLib.Forms.Browsing.ComputerBrowserDialog') 
print(dialog.ShowDialog())

# Display results
print(dialog.SelectedName)
REM This example shows how to let the user browse for computers on the network.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    Dim Dialog As New ComputerBrowserDialog
    Dim DialogResult
    DialogResult = Dialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    OutputText = OutputText & Dialog.SelectedName & vbCrLf
End Sub
Rem This example shows how to let the user browse for computers on the network.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Const DialogResult_OK = 1

Dim Dialog: Set Dialog = CreateObject("OpcLabs.BaseLib.Forms.Browsing.Specialized.ComputerBrowserDialog")
Dim dialogResult: dialogResult = Dialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo Dialog.SelectedName

Python

# This example shows how to let the user browse for computers on the network.
#
# 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 .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.BaseLib.Forms.Browsing.Specialized import *


dialog = ComputerBrowserDialog()
print(dialog.ShowDialog())

# Display results.
print(dialog.SelectedName)

print('Finished.')

 

 

Icon:

With ComputerBrowserDialog object, you can present your user with a dialog for selecting the remote computer where the OPC server resides.

For more information, see the Computer Browser dialog under “User Interface for OPC-DA”.

 

Example
// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System.Windows.Forms;
using OpcLabs.BaseLib.Forms.Browsing.Specialized;

namespace UAFormsDocExamples._ComputerBrowserDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var computerBrowserDialog = new ComputerBrowserDialog();

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

            // Display results
            MessageBox.Show(owner, computerBrowserDialog.SelectedName);
        }
    }
}
# This example shows how to let the user browse for computers on the network.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.

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

$computerBrowserDialog = New-Object OpcLabs.BaseLib.Forms.Browsing.Specialized.ComputerBrowserDialog

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

# Display results
Write-Host $computerBrowserDialog.SelectedName
' This example shows how to let the user browse for computers on the network.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
' a commercial license in order to use Online Forums, and we reply to every post.

Imports OpcLabs.BaseLib.Forms.Browsing.Specialized

Namespace UAFormsDocExamples._ComputerBrowserDialog
    Friend Class ShowDialog
        Shared Sub Main1(owner As IWin32Window)
            Dim computerBrowserDialog = New ComputerBrowserDialog()

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

            ' Display results
            MessageBox.Show(owner, computerBrowserDialog.SelectedName)
        End Sub
    End Class
End Namespace
// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _ComputerBrowserDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _ComputerBrowserDialogPtr DialogPtr(__uuidof(ComputerBrowserDialog));

            // 
            DialogResult dialogResult = DialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);
            
            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _tprintf(_T("%s\n"), (LPCTSTR)CW2CT(DialogPtr->SelectedName));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ShowDialog.Main;
var
  Dialog: ComputerBrowserDialog;
begin
  // Instantiate the dialog object
  Dialog := CoComputerBrowserDialog.Create;

  Dialog.ShowDialog(nil);
  // IMPROVE: check the dialog result

  WriteLn(Dialog.SelectedName);
end;
// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

class procedure ShowDialog.Main;
var
  ComputerBrowserDialog: OpcLabs_BaseLibForms_TLB._ComputerBrowserDialog;
  DialogResult: System_Windows_Forms_TLB.DialogResult;
begin
  // Instantiate the dialog object
  ComputerBrowserDialog := CoComputerBrowserDialog.Create;

  DialogResult := ComputerBrowserDialog.ShowDialog(nil);
  WriteLn(DialogResult);

  if DialogResult <> DialogResult_OK then
    Exit;

  // Display results
  WriteLn(ComputerBrowserDialog.SelectedName);
end;
// This example shows how to let the user browse for computers on the network.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

$Dialog = new COM("OpcLabs.BaseLib.Forms.Browsing.Specialized.ComputerBrowserDialog");
printf("%d\n", $Dialog->ShowDialog);

// Display results
printf("%s\n", $Dialog->SelectedName);
# This example shows how to let the user browse for computers on the network.
#
# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
import win32com.client

dialog = win32com.client.Dispatch('OpcLabs.BaseLib.Forms.Browsing.ComputerBrowserDialog') 
print(dialog.ShowDialog())

# Display results
print(dialog.SelectedName)
REM This example shows how to let the user browse for computers on the network.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    Dim Dialog As New ComputerBrowserDialog
    Dim DialogResult
    DialogResult = Dialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    OutputText = OutputText & Dialog.SelectedName & vbCrLf
End Sub
Rem This example shows how to let the user browse for computers on the network.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Const DialogResult_OK = 1

Dim Dialog: Set Dialog = CreateObject("OpcLabs.BaseLib.Forms.Browsing.Specialized.ComputerBrowserDialog")
Dim dialogResult: dialogResult = Dialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo Dialog.SelectedName
# This example shows how to let the user browse for computers on the network.
#
# 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 .
# Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
# a commercial license in order to use Online Forums, and we reply to every post.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.BaseLib.Forms.Browsing.Specialized import *


dialog = ComputerBrowserDialog()
print(dialog.ShowDialog())

# Display results.
print(dialog.SelectedName)

print('Finished.')
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.CommonDialog
            OpcLabs.BaseLib.Forms.ConcreteCommonDialog
               OpcLabs.BaseLib.Forms.Browsing.Specialized.ComputerBrowserDialog

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