PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview of a .NET object
  • Syntax for declaring a .NET object
  • Declaring a .NET object
  • The members of a .NET object
  • Note: Problems with the case
  • The methods of a .NET object
  • Note: Problems with the case
  • Lifespan of a .NET object
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview of a .NET object
To access a .NET class, the .NET object must be declared as being part of the class to handle, this is called instantiation of a .NET object.
An instance is a .NET object that belongs to a given .NET class.
To handle a .NET object, you must:
  1. Import the.NET assembly (see Using .NET assemblies in a WINDEV application for more details).
  2. Declare the .NET object as being an object of one of the assembly classes. A .NET object can be passed in parameter to a function or to a procedure.
Note: You can dynamically instantiate a .NET object to a class. See Dynamic instantiation of .NET object for more details.
Syntax for declaring a .NET object

Declaring a .NET object

<Name of .NET Object> is [object] <Name of .NET Class>([<Parameters>])
where:
  • <Name of .NET Object>: Name that identifies the instance of the class.
  • <Name of .NET Class>: Name identifying the class. If the .NET class is named like a WLanguage keyword, the name of the class must be enclosed in quotes (for example, o is "<Class>"(<Parameters>).

    To use a class by specifying the namespace, the full name of the class must be enclosed in quotes. For example:
    var3 is "Microsoft.CRM.Proxy.CRMAccount"

    Versions 21 and later
    To use a generic, the name of the generic must be enclosed in quotes. For example:
    MyList is "List<CMyObject>"
    New in version 21
    To use a generic, the name of the generic must be enclosed in quotes. For example:
    MyList is "List<CMyObject>"
    To use a generic, the name of the generic must be enclosed in quotes. For example:
    MyList is "List<CMyObject>"
  • <Parameters>: Optional parameters of the constructor. See Constructor method for more details.
The members of a .NET object
A member of an object is a data associated with the object.
To access the members, use the following syntaxes:
  1. Calling a member that belongs to an object other than the current object:
    <Object Name>: <Member Name>

    The member is sought among the members of the object class. If the member is not found, it is sought among the members of the ancestor classes of the object class.
  2. Calling a member of the current object:
    : <Member Name>
  3. Calling a member of an ancestor class that was redefined:
    <Object Name>: <Class Name>:: <Member Name>
  4. Calling a member of a general class:
    <Class Name>:: <Member Name>

Note: Problems with the case

Sometimes, two members of a .NET object have the same name except for the case (uppercase/lowercase characters). In this case, WINDEV gives priority to the member that is using the case entered in the code editor.
Reminder: To avoid using the automatic completion in the code editor of WINDEV, all you have to do is ignore the suggestion made by WINDEV (do not press the ENTER key).
The methods of a .NET object
The methods of an object are features associated with the object.
  1. Calling a method that belongs to an object other than the current object:
    <Object Name>: <Method Name> ([<Parameters>])

    The member is sought among the methods of the object class. If the method is not found, it is sought among the methods of the ancestor classes of the object class.
  2. Versions 21 and later
    Calling a generic method:
    <Object Name>: "<Method Name><<Concrete Type>>" ([<Parameters>])

    Example for calling a generic method:
    // Prototype of the generic CloneList method of CClone class
    // CloneList(List<T>)
    // ...
    MyList is "List<int>"
    // ...
    clClone is CClone
    MyListCopy is "List<int>" <- clClone."CloneList<int>"(MyList)
    New in version 21
    Calling a generic method:
    <Object Name>: "<Method Name><<Concrete Type>>" ([<Parameters>])

    Example for calling a generic method:
    // Prototype of the generic CloneList method of CClone class
    // CloneList(List<T>)
    // ...
    MyList is "List<int>"
    // ...
    clClone is CClone
    MyListCopy is "List<int>" <- clClone."CloneList<int>"(MyList)
    Calling a generic method:
    <Object Name>: "<Method Name><<Concrete Type>>" ([<Parameters>])

    Example for calling a generic method:
    // Prototype of the generic CloneList method of CClone class
    // CloneList(List<T>)
    // ...
    MyList is "List<int>"
    // ...
    clClone is CClone
    MyListCopy is "List<int>" <- clClone."CloneList<int>"(MyList)
  3. Versions 21 and later
    Calling an extension method:
    <Object Name>: <Method Name> ([<Parameters>])

    The extension methods can be called like the methods of the object.
    New in version 21
    Calling an extension method:
    <Object Name>: <Method Name> ([<Parameters>])

    The extension methods can be called like the methods of the object.
    Calling an extension method:
    <Object Name>: <Method Name> ([<Parameters>])

    The extension methods can be called like the methods of the object.

Note: Problems with the case

In some cases, two methods of a .NET object have the same name except for the case (uppercase/lowercase characters). In this case, WINDEV gives priority to the method that is using the case entered in the code editor.
Reminder: To avoid using the automatic completion in the code editor of WINDEV, all you have to do is ignore the suggestion made by WINDEV (do not press the ENTER key).
Lifespan of a .NET object
The object is created during its declaration. The object is local by default.
The object is automatically destroyed at the end of the process containing its declaration:
  • An object declared in the initialization code of a window will be destroyed at the end of the closing process of the window.
  • An object declared global in the initialization code of a project will be destroyed at the end of the closing process of first project window.
Related Examples:
WD Active Directory DotNet Training (WINDEV): WD Active Directory DotNet
[ + ] This example is used to view the content of an Active Directory.
This viewing is performed via.NET objects found in the System.DirectoryServices assembly. You have the ability to view the properties of the users and to authenticate the users via their password.
You also have the ability to view information (more or less according to your rights) by specifying the name of your Active Directory server
WD Manager of task DotNet Complete examples (WINDEV): WD Manager of task DotNet
[ + ] This example is used to list the applications and the processes via .Net functions.

Furthermore, it is used to perform different processes on the applications (Toggle to an application, Maximize, Minimize, and so on) and on the processes (change the priority or end the process).
This example uses the main features of a task manager.
WD DirectoryObserver Training (WINDEV): WD DirectoryObserver
[ + ] This example presents the use of the WLanguage function named fTrackDirectory.
It is used to watch a directory,
which means to be informed whenever a modification is performed in this directory.
A modification can be:
- Adding a file or a directory
- Renaming
- Modifying a file
- Deleting a file
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment