Examples of How to Use Each Function
NEMGetFile
Declare Function NEMGetFile Lib «nnotesws» ( wHandle As Integer, Byval szFileName As String, Byval szFilter As String, Byval szTitle As String ) As Integer
Sub Click(Source As Button)
‘Declare variables…
Dim szFileName As String*256
Dim szTitle As String
Dim szFilter As String
Dim szSelectedFile as String
‘Set values…
szFilename = Chr(0)
szTitle = «Open File»
szFilter = «All Files |*.*|Word Document |*.doc|Text Files|*.txt|»
If NEMGetFile( 0, szFileName, szFilter, szTitle) <> 0 Then
szSelectedFile = szFileName
End If
End Sub
NEMPutFile
Declare Function NEMPutFile Lib «nnotesws» ( wHandle As Integer, Byval szFileName As String, Byval szFilter As String, Byval szTitle As String ) As Integer
Sub Click(Source As Button)
‘Declare variables…
Dim szFileName As String*256
Dim szTitle As String
Dim szFilter As String
Dim szSaveFile as String
‘Set values…
szFilename = Chr(0)
szTitle = «Save File»
szFilter = «All Files |*.*|Word Document |*.doc|Text Files|*.txt|»
If NEMPutFile( 0, szFileName, szFilter, szTitle) <> 0 Then
szSaveFile = szFileName
End If
End Sub
NEMMessageBox
Declare Function NEMMessageBox Lib «nnotesws» ( wHandle As Integer, Byval szMessage As String, Byval szTitle As String, Byval wType As Integer) As Integer
Sub Click(Source As Button)
‘wType follows the same construct as the messagebox LotusScript function
‘0 = OK, 20 = YesNO, 17 = OK and Cancel and so on…
Call NEMMessageBox(0, «Message to display», «Title of Message box», 19)
End Sub
NEMGetCurrentSubprogramWindow and NEMStopSubprogramWindow
Declare Function NEMGetCurrentSubprogramWindow Lib «nnotesws.dll» () As Long
Declare Function NEMStopSubprogramWindow Lib «nnotesws.dll» (Byval wHandle As Long) As Integer
Sub Click(Source As Button)
‘Declare variables…
Dim wHandle As Long
‘ Get window handle…
wHandle = NEMGetCurrentSubprogramWindow
‘ Close current window…
Call NEMStopSubprogramWindow(wHandle)
End Sub
NEMEnableWaitCursor
Declare Function NEMEnableWaitCursor Lib «nnotesws.dll» () As Long
Sub Click(Source As Button)
Call NEMEnableWaitCursor
End Sub
NEMDisableWaitCursor
Declare Function NEMDisableWaitCursor Lib «nnotesws.dll» () As Long
Sub Click(Source As Button)
Call NEMDisableWaitCursor
End Sub
NEMDisplayMessage
Declare Function NEMDisplayMessage Lib «nnotesws» (Byval wMessageNumber As Integer) As Integer
Sub Click(Source As Button)
Call NEMDisplayMessage(19) ‘Loads a string resource from NSTRINGS.DLL and displays messagebox…
End Sub
NEMDisplayError
Declare Function NEMDisplayError Lib «nnotesws» (Byval wType As Integer) As Integer
Sub Click(Source As Button)
Call NEMDisplayError(24) ‘Loads a string resource from NSTRINGS.DLL and displays error box…
End Sub
NEMDisplayError1
Declare Function NEMDisplayError1 Lib «nnotesws» (Byval wType As Integer, Byval szMessage As String) As Integer
Sub Click(Source As Button)
‘Loads a string resource from NSTRINGS.DLL, appends text and displays error box…
Call NEMDisplayError1(24, «Primeapple Software»)
End Sub
NEMBeep
Declare Function NEMBeep Lib «nnotesws» () As Integer
Sub Click(Source As Button)
Call NEMBeep
End Sub
DeskLocateOrAddEntry
Declare Function DeskLocateOrAddEntry Lib «nnotesws» (Byval szPath As String) As Integer
Sub Click(Source As Button)
‘Declare variables…
Dim iRetVal As Integer
‘Add icons to desktop — Note structure for server based and local databases…
iRetVal = DeskLocateOrAddEntry(«log.nsf»)
iRetVal = DeskLocateOrAddEntry(«PrimeServer1!!products\riodb.nsf»)
‘Display error message if appropriate — useful demo of NEMDisplayError function call…
If iRetVal <>0 Then NEMDisplayError(iRetVal)
End Sub
NEMPostStatus
Declare Function NEMPostStatus Lib «nnotesws.dll» (Byval szText As String) As Long
Sub Click(Source As Button)
Call NEMPostStatus(«Primeapple Software is cool»)
End Sub
NEMProgress…
Const NPB_TWOLINE% = 1
Const NPB_STATUSBAR% = 32
Declare Function NEMProgressBegin Lib «nnotesws.dll» ( Byval wFlags As Integer ) As Long
Declare Sub NEMProgressDeltaPos Lib «nnotesws.dll» ( Byval hwnd As Long, Byval dwIncrement As Long )
Declare Sub NEMProgressEnd Lib «nnotesws.dll» ( Byval hwnd As Long )
Declare Sub NEMProgressSetBarPos Lib «nnotesws.dll» ( Byval hwnd As Long, Byval dwPos As Long)
Declare Sub NEMProgressSetBarRange Lib «nnotesws.dll» ( Byval hwnd As Long, Byval dwMax As Long )
Declare Sub NEMProgressSetText Lib «nnotesws.dll» ( Byval hwnd As Long, Byval pcszLine1 As String, Byval pcszLine2 As String )
Sub Click(Source As Button)
‘Declare variables…
Dim hwnd As Long
Dim i As Long
Dim j As Long
‘Create the progress bar…
hwnd = NEMProgressBegin( NPB_TWOLINE )
‘Set the bar range — the default is 100…
NEMProgressSetBarRange hwnd, 200
‘Display some text on the dialog. The second line is ignored if NPB_TWOLINE not specified…
NemProgressSetText hwnd, «Calculating..», «Start»
For i = 0 To 200
‘Simple delay loop to give us time to see whats going on…
For j = 0 To 5000
Next
‘Update the bar position — we could also use NEMProgressDeltaPos hwnd, 1 here…
NEMProgressSetBarPos hwnd, i
‘Update the text at halfway…
If i = 100 Then
NEMProgressSetText hwnd, «Calculating», «Half way»
End If
Next
‘Destroy the dialog when we’re done…
NEMProgressEnd hwnd
End Sub
NEMProgress… (Declared as a Class)
The class LNProgressbar should be pasted into the Declarations in a Lotus script library.
Declare Public Function NEMProgressBegin Lib «nnotesws.dll» ( Byval wFlags As Integer ) As Long
Declare Public Sub NEMProgressDeltaPos Lib «nnotesws.dll» ( Byval hwnd As Long, Byval dwIncrement As Long )
Declare Public Sub NEMProgressEnd Lib «nnotesws.dll» ( Byval hwnd As Long )
Declare Public Sub NEMProgressSetBarPos Lib «nnotesws.dll» ( Byval hwnd As Long, Byval dwPos As Long)
Declare Public Sub NEMProgressSetBarRange Lib «nnotesws.dll» ( Byval hwnd As Long, Byval dwMax As Long )
Declare Public Sub NEMProgressSetText Lib «nnotesws.dll» ( Byval hwnd As Long, Byval pcszLine1 As String, Byval pcszLine2 As String )
Const NPB_TWOLINE = 3
Const NPB_ONELINE = 2
Public Class LNProgressbar
hwnd As Long
Sub New(SecondLineVisible As Integer)
‘Set-up the progress bar on the screen
If SecondLineVisible Then
hwnd = NEMProgressBegin(NPB_TWOLINE)
Else
hwnd = NEMProgressBegin(NPB_ONELINE)
End If
End Sub
Sub SetText(FirstLineText As String,SecondLineText As String)
‘Display the text in progress bar
NemProgressSetText hwnd, FirstLineTExt,SecondLineText
End Sub
Sub SetProgressPos(Progresspos As Long)
NEMProgressSetBarPos hwnd, ProgressPos
End Sub
Sub SetProgressRange(ProgressMaxElements As Long)
‘Set-up the max elements in the progress bar, if you have
‘a list with 230 elements then set the MAX to 230 elements.
‘For every element you proceed increase the SetProgressPos
‘by one to reached 230
NEMProgressSetBarRange hwnd, ProgressMaxElements
End Sub
Sub DeltaPos(DPos As Long)
‘ This function adds the number in DPOS to the current ProgressPos
NEMProgressDeltaPos hwnd, DPos
End Sub
Sub Delete
‘Terminate the progress bar on the screen
NEMProgressEnd hwnd
End Sub
End Class
‘Sample to test the code. You can paste this code into the click event of a button
‘We need two lines on the progress bar
Dim pb As New LNProgressBar(True)
Dim i As Long
Call pb.SetText(«This is line one»,»This is line two»)
‘We set the range to 200 elements
Call pb.SetProgressRange(200)
For i=1 To 200
‘we process the elements
Call pb.SetProgressPos(i)
Next
‘Terminate the progress bar
Delete pb