Manage Learn to apply best practices and optimize your operations.

Optimize Notes startup for different screen resolutions

I created a new corporate homepage and found it difficult to optimize it for all screen resolutions.

I was finding it difficult to optimize my corporate homepage for different screen resolutions, so I created four separate framesets, each optimized to a different resolution, from 640x480 to 1280x1024.

Here is how I determined the resolution. The user32 dynamic link library has accessor functions available that allow to you efficiently retrieve that information. By putting that functionality into the homepage's database script post-open event, I am able to determine the screen resolution of the PC each time it opens the database. I am writing that value to an environment variable. Each time I open the database, via the post-open event, I am testing whether the current resolution is changed from the last time that the environment variable was written. Every time someone opens this database, the current resolution is written to this environment variable.

I created another frameset as a host to one of the four framesets mentioned above, to be determined at runtime via a computed formula based upon the dynamic value representing the screen resolution. This host is a one-frame frameset, populated with the computed value listed below. This is the database's default frameset as defined within the database properties.

Database script code:

 Type RECT
 x1 As Long
 y1 As Long
 x2 As Long
 y2 As Long
End Type

Declare Function GetDesktopWindow Lib 
"User32" () As Long Declare Function 
GetWindowRect Lib "User32" (Byval 
hWnd As Long, rectangle As Rect) As Long

And within the PostOpen event:
Dim session As New NotesSession
currentRes = getResolution.FormLoad()
  tempRes = session .
  If (tempRes <> currentRes) And 
(tempRes <> "") Then
   Messagebox "Notes has detected a 
change in your screen 
resolution.  The next time you start the 
Corporate Intranet, the homepage will 
be adjusted to optimize your new resolution 
setting.", 0 + 64, "Screen 
Resolution Change" 
  Elseif tempRes = "" And currentRes 
<> "800x600" Then
   Messagebox "Your screen resolution 
has been detected 
as " & currentRes & ". Your intranet will
 be optimized for this display setting 
and will be used the next time that you login. 
 For this session, the default 
of 800x600 will be used.", 0 + 64,
 "Screen resolution settings" 
  Elseif  tempRes = "" And currentRes =
 "800x600" Then
   Messagebox "Your screen resolution
 has been detected 
as " & currentRes & ". This is the default 
resolution setting for the Corporate 
Intranet as well, therefore no changes 
need to be applied.", 0 + 64, "Screen 
resolution settings" 
  End If
  Call session.SetEnvironmentVar
( "currentRes", currentRes )   
Add this function:
Function FormLoad() As String
 Dim workspace As New NotesUIWorkspace
 Dim R As Rect
 Dim hWnd As Long
 Dim RetVal As Long
 Dim GetScreenResolution As String
 hWnd = GetDesktopWindow ()
 RetVal = GetWindowRect(hWnd, R)
 GetScreenResolution = (R.x2 - R.x1) 
& "x" & (R.y2 - R.y1)
 FormLoad = GetScreenResolution
End Function

Finally, the code that goes within the default frameset to determine which frameset to actually display (I have named the framesets with the resolution that they represent):

temp := @Environment("currentRes");
@If(temp = "640x480";"640x480";
@If(temp = "800x600";"800x600";@If(temp 
= "1024x768";"1024x768";@If(temp = 
= "1280x1024";"1280x1024";"800x600")))))

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member Andrew Young. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on LotusScript



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury