Thursday, May 1, 2008
Microsoft Access Team made an interesting post and a follow-up on how to add a transparent layer that cover the screen to focus the attention of the user to a login form or other important popup window.
The trick is to use some WIN 32 API calls to modify the transparency of a standard MS Access form made to cover the screen.
The effect is quite neat and I thought I would try it and make a sample database for others to tinker with it.
My version allows you to chose between covering the whole screen or just the main Access window and it will test if it’s running under a Remote Desktop Terminal and disable the layer in that case.
Following Rob’s improvements I made another sample database that incorporates his code with a few improvements:
- I added the
LightBoxForm.LayerToFullScreenproperty so users can choose explicitly how they want the layer to be shown.
- I moved the code to hide the layer into a Hide() sub so you can just show/hide the layer using
- I changed the Form’s
Resizeevent code in the
LightBoxFormclass to avoid flickering: resizing the form within its
Resizeevent actually trigger the
Resizeevent again a second time which causes flickering.
I simply modified the code to make the form totally transparent (opacity of 0) the first time the event is fired and assign it the expected opacity when the event handler in re-entered.
There are now 2 sample databases. Ech zip contains a Microsoft Access 2007 ACCDB file and its conversion to Access 20001 and Access 2002-2003 MDB but please note that I have not been been able to test those in older version of Access and that form transparency doesn’t work in Operating Systems older than Windows 2000.
- If you are getting security warnings: make sure that you open the database from a Trusted Location or you will receive a security prompt. If you don’t know how to do that, check these steps.
- If the layer appears on top of the login form instead of behind: make sure that the top-most form has ist
Modalproperties set to
frmLightBoxform has its modal property set to
If you improve on it, please let me know and I’ll post it here for all to find.
A specific version for Access 2000 now included in the archive (updated 25JUL2008). ↩