Executing Windows/32 Control Panel applets from LotusScript is easy. Suffice to code a Shell statement appending the applet name to the control program and the job is done. The following code sample opens up "Display Properties" and "Tweak UI" control panel dialogs.
Dim TaskID As Integer
taskID% = Shell( "control desk.cpl" ) ' Let's open up "Display Properties" window ..
taskID% = Shell( "tweakui.cpl" ) ' .. then "Tweak UI" dialog box afterwards.
Applets shelled this way run independently from Notes applications whereas the ability to execute applets in Notes threads is tied to your client operating system. Nir Sofer's site [1] details how Visual Basic programmers can display Control Panel applets within modal dialog boxes. Nir achieves this performing Windows API calls and using VarPtr() Visual Basic only statement. While VarPtr() is not supported in LotusScript, designers with appropriate Windows/32 C API experience, can implement equivalent functionality. Thus Nir's Visual Basic code ..
Private Declare Function CPlApplet_Main Lib "main.cpl" Alias "CPlApplet" _
( ByVal hwndCPl As Long, ByVal uMsg As Long, ByVal lParam1 As Long, _
ByVal lParam2 As Long ) As Long
Private Sub MainCplApplet( lParam1 As Long )
If CPlApplet_Main( hWnd, CPL_INIT, 0, 0 ) <> 0 Then
CPlApplet_Main hWnd, CPL_INQUIRE, lParam1, VarPtr( ci )
CPlApplet_Main hWnd, CPL_DBLCLK, lParam1, ci.lData
CPlApplet_Main hWnd, CPL_STOP, 0, ci.lData
CPlApplet_Main hWnd, CPL_EXIT, 0, 0
End If
.. can be translated into LotusScript as:
Declare Private Function Applet Lib "main.cpl" Alias "CPlApplet" _
( Byval hwndCPl As Long, Byval uMsg As Long, Byval lParam1 As Long, _
Byval lParam2 As Long ) As Long
Declare Private Function AppletVarPtr Lib "main.cpl" Alias "CPlApplet" _
( Byval hwndCPl As Long, Byval uMsg As Long, Byval lParam1 As Long, _
lParam2 As CPLINFO ) As Long ' NOTE the last argument modification HERE !
If Applet( hwnd, CPL_INIT, 0, 0 ) <> 0 Then
' Visual Basic VarPtr() statement does not exist in LotusScript ...
AppletVarPtr hwnd, CPL_INQUIRE, lParam1, ci
' ... AppletVarPtr declare is emulating VarPtr(ci) statement
CPlApplet_Main hWnd, CPL_DBLCLK, lParam1, ci.lData
CPlApplet_Main hWnd, CPL_STOP, 0, ci.lData
CPlApplet_Main hWnd, CPL_EXIT, 0, 0
End If
Note AppletVarPtr() above function in Windows C API second declare statement, its last argument is defined as a CPLINFO structure. It is sent by reference instead of being sent by value which emulates VarPtr() Visual Basic statement. All control panel applets can be called this way. I decided not to code numerous declares, but used an APPLET_CODE_TEMPLATE string where AppletName and lParam1 arguments are dynamically substituted. This way applets are loaded and executed at runtime as in:
Private Sub AppletLoader( Byval appletName As String, Byval parm1 As String )
toList( 0 ) = appletName
toList( 1 ) = parm1
' Domino Release 6 ONLY
Execute Replace( APPLET_TEMPLATE_CODE, fromList, toList )
End Sub
I wrapped up a few applets' calls in a ControlPanel class bundled in OpenDOM open source project that you can download from OpenNTF.org site. You can use it as shown below:
Use "LotusScript.windows.win32"
Dim ui As New ControlPanel
ui.AccessibilityOptions
ui.DisplayProperties
ui.MultimediaProperties
ui.AppletLoader "tweakui", "0"
I hope you'll find ControlPanel class useful and shall be glad to hear about any interesting usage you experiment with it or about any extensions you make to it.
Credit: [1] Executing Control Panel applets
Labels: Control Panel, Lotus Notes, LotusScript, SnTT, Windows API