OpenDOM

Saturday, December 30, 2006

Opening Control Panel applets in modal dialog boxes - Windows/32 only

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: , , , ,

Thursday, December 14, 2006

Plot Undocumented DOM LotusScript Using Visual Basic 2005 Express free Edition

Today's post is a three steps introspection guide to «Lotus Notes Automation Classes» best kept secrets.

1. Suffice to add a new reference to your .NET project using Project - Add reference... menu.

As an alternative you can equally right-click Solution explorer window and select Add reference...
2. You then select «Lotus Notes Automation classes» from the COM tab component list. Activate the class browser either keying F2 either selecting View - Object browser command menu.

3. You can now explore the lotus package classes and view their attributes and operations.

Note that depending on your PC's color palette undocumented properties and methods will be denoted in light grey.

Using Microsoft C# 2005 Express free Edition functions equally. I guess any other professional .NET toolkit would work just as well. Note that latest #Develop open source IDE does not provide COM libraries equivalent expansion.

Labels: , ,