Object-oriented LotusScript

Source: Internet
Author: User
The benefits of using object-oriented LotusScript are described last time. Two examples are provided here. DialogBox is a NotesUIWorkspace method used to display a dialog box for a specified form. It is useful in development. However, many settings in the dialog box are passed through the parameters of the method, so it is hard to remember that the benefits of using object-oriented LotusScript are mentioned last time. Here we provide two examples. DialogBox is a NotesUIWorkspace method used to display a dialog box for a specified form. It is useful in development. However, many settings in the dialog box are passed through the parameters of the method, which is hard to remember. The following uses a custom class to wrap the DialogBox function. By default, you only need to input a form or document parameter to call the Show () method to display a dialog box. You can set attributes to adjust the dialog box. The original parameters are classified according to their meaning, which makes it easier to set. For example, the Fit attribute can control the HorizonalFit and VerticalFit settings, and the AllowUpdate attribute can control NoFieldUpdate and NoNewFields. If necessary, you can also use public fields to modify the original parameters more precisely. [Vb] % REM Class DialogBox Description: Wraps the ws. dialogbox () method. % end rem Public Class DialogBox Public FormName As String Public HorizonalFit As Boolean Public VerticalFit As Boolean Public NoCancel As Boolean Public NoNewFields As Boolean Public NoFieldUpdate As Boolean Public ReadOnly As Boolean Public Title As String Public Document as NotesDocument Public SizeToTable As Boolean Public NoOKCancel As Boolean Public OKCancelAtBottom As Boolean % REM Property Set Fit Description: Wraps the HorizonalFit and VerticalFit fields % end rem Property Set Fit As Boolean me. horizonalFit = Fit me. verticalFit = Fit End Property % REM Property Set AllowUpdate Description: Wraps the NoFieldUpdate and NoNewFields fields % end rem Property Set AllowUpdate As Boolean me. noFieldUpdate = Not AllowUpdate me. no NewFields = Not AllowUpdate End Property % REM Property Set DefaultButton Description: Wraps the NoCancel and NoOKCancel fields % end rem Property Set DefaultButton As Boolean me. noCancel = Not DefaultButton me. noOKCancel = Not DefaultButton End Property % REM Sub New Description: The argument info is either a string of a form name or a document to be shown % end rem Public Sub New (info As Variant) 'stop' D Efault values me. horizonalFit = False me. verticalFit = False me. noCancel = False me. noFieldUpdate = False me. noNewFields = False me. noOKCancel = False me. OKCancelAtBottom = False me. readOnly = False me. sizeToTable = False me. title = "Lotus Notes" Select Case TypeName (info) Case "NOTESDOCUMENT" Set me. document = info me. formName = info. form (0) Case "STRING" 'info is the form name me. formName = info Set me. document = CreateDoc (Me. formName) End Select End Sub % REM Function Show Description: Show the dialogbox. % end rem Public Function Show () As Boolean Dim ws As New NotesUIWorkspace Show = ws. dialogbox (Me. formName, Me. horizonalFit, Me. verticalFit, Me. noCancel, Me. noNewFields, Me. noFieldUpdate, Me. readOnly, Me. title, Me. document, Me. sizeToTable, Me. noOKCancel, Me. OKCancelAtBottom) The user-defined Class under the End Function End Class Collection is also packaged in a similar way. By default, a view of the current database is opened, and multiple choices and one choice are made through SelectDocs and SelectDoc. [Vb] % REM Class PickBox Description: Wraps the ws. picklistcollection () method. % end rem Public Class PickBox Private ws As NotesUIWorkspace Private s As NotesSession Private db As NotesDatabase Public MultiSelect As Boolean Public Server As String Public DBPath As String Public Title As String Public Prompt As String Public SingleCategory as String % REM Sub New Description: comments for Sub % end rem Sub New () Set ws = New NotesUIWorkspace Set s = New NotesSession Set db = s. currentdatabase 'default to open a view in the current db. server = db. server DBPath = db. filepath Title = "Lotus Notes" Prompt = "Please select the document (s ). "End Sub % REM Function SelectDocs Description: MultiSelect, return a NotesDocumentCollection % end rem Public Function SelectDocs (viewName As String) As NotesDocumentCollection Set SelectDocs = ws. picklistcollection (PICKLIST_CUSTOM, MultiSelect, Server, DBPath, ViewName, Title, Prompt, Singlecategory) End Function % REM Function SelectDoc Description: Return a single NotesDocument. % end rem Public Function SelectDoc (viewName As String) As NotesDocument me. multiSelect = False Set SelectDoc = me. selectDocs (viewName ). the following is a simple example of using the above two classes: [vb] Dim dlgbox As New DialogBox ("formName") With dlgbox. defaultButton = True. allowUpdate = False End With Dim result As Boolean result = dlgbox. show () Dim pb As New PickBox Dim doc As NotesDocument Set doc = pb. selectDoc ("viewName ")
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.