77家的会客2010

Lotus Notes中C/S模式下进度条的使用

实现有两种方法,第一种比较简单,就是在status栏里print出文本,不过这个方法比较笨,但是很保险,基本上不会出什么问题。代码如下:

REM "From Erden Eruc @ NGSINC"

Dim i As Integer
Dim s As String
     
'Is this 100 meter dash? no it is a meter with 100 dashes :)
     
s = "--------------------------------------------"&_
"--------------------------------------------------------"
For i = 1 To 100
  s = Left( Chr(1) & s, 100 )
  If i<10 Then
    Print "Percent Done:    "& Str(i)&"% - " & s 
  Elseif i = 100 Then
    Print "Percent Done:"& Str(i)&"% - " & s
  Else
    Print "Percent Done:  "& Str(i)&"% - " & s
  End If
Next
Print "Percent Done: 100% - Job complete..."

 

另一种就是NOTES本身带的那种图形界面的,这个当然对用户比较友好,但由于NOTES并没有公开这个API,我们就不得不自己来调用了,如下面代码,使用下面的代码有一定风险,如果是在DEBUG模式,或是使用过程中出错了,那么整个NOTES客户端会被lock住,所以使用下面代码的时候,一定要加异常处理,确保代码最后一句一定要被执行。

For a Win32-specific version that uses Notes functions (note: this is a dangerous thing to do, but if you really must have a graphical progress bar..):
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 )
' From Mark Dixon @ Ives

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

 

以上代码来自于:http://www.keysolutions.com/notesfaq./howprogress.html

历史上的今天: [2005/07/26]Ajax首试,成功
[2005/07/26]ColdFusion中定时跳页的三种方法
[2005/07/26]FCKeditor 2.0在线编辑器的设置与修改以及使用

[Lotus Notes中C/S模式下进度条的使用]的回复

Post a Comment~