Approach User Support homepage Approach User Support
Answers to Frequently Asked Questions about Lotus Approach
Examples LotusScripts
Example databases
Links to other Lotus Approach support services

[Return to contents]

Example LotusScript: Controlling the window size when opening Approach

Last updated: 4 Jan 2004

Dave Legge writes:

Cut and paste this, into the Lotus Script Editor

In Declarations, put:

Public Type RECT
 Left As Long
 Top As Long
 Right As Long
 Bottom As Long
End Type
Declare Public Function GetDesktopWindow Lib "user32" _  'The GetDesktopWindow function returns the handle of the Windows desktop window.
Alias "GetDesktopWindow" () As Long     'The desktop window covers the entire screen.
Declare Public Function GetClientRect Lib "user32" _
Alias "GetClientRect" (Byval hwnd As Long, lpRect As RECT) As Long
Declare Public Function  MoveWindow Lib "user32"  _
Alias "MoveWindow" (Byval hwnd As Long,  Byval x As Integer, Byval y As Integer,Byval  w As Integer,Byval h As Integer, Byval repaint As Integer) As Long

In globals, put:

Sub AprWindowsize( wide As Long, high As Long)
'Set Approach application window to wide x high  (in pixels)
' and center it on desktop
 Dim Hdesktop As Long
 Dim Hapr As Long
 Dim RDesktop As rect
 Dim Rapr As rect
 Dim ok As Long
 Dim lft As Long
 Dim top As Long

 Hdesktop = GetDesktopWindow
 GetClientRect  Hdesktop , Rdesktop
 Hapr =Currentapplication.applicationWindow.Gethandle
 If (wide>RDesktop.right) Or (high>Rdesktop.bottom) Then
  Currentapplication.applicationWindow.maximize
 Else
  Hapr = Currentapplication.applicationwindow.gethandle
  GetClientRect Hapr , Rapr
  lft =    (Rdesktop.right-wide) / 2
  top = (Rdesktop.bottom-high)/2
  MoveWindow  Hapr, lft,top,wide,high,1  ' h,x,y,w,h,true
 End If
End Sub

Then in your-document's DocumentWindow, "OpenWindow" Script put:

AprWindowsize 790, 595

It resizes and centers on the screen

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.