Win API Calls in VBA Need Clarification

J

Jay

Hi –

I’m developing an MS-Access application (with VBA) and I’d like to hide the
Access main window while showing a single, custom user form inside my
application. My web research uncovered some chatter about doing this and
I’ve tried several suggested solutions with no success.

Currently, I’m experimenting with some code posted by Graham Seach to
address the technique of hiding the container application window; it looks
like it has a lot of potential, but I’m inexperienced with Windows API and
I’m having trouble getting his code to run. Specifically, he didn’t supply
the declaration statements and I also don’t fully understand where the
function argument values come from.

Any help tuning up Graham’s following code would be appreciated.

Thanks,
Jay
-----------
'Set the Popup property of each form that you want to display, to True. Then
'call the code shown below like so:
Sub transparent()
SetAccessWindowOpacity 0
End Sub

'To display the Access window, call the code like so:
Sub notTransparent()
SetAccessWindowOpacity 255
End Sub

Public Sub SetAccessWindowOpacity(Opacity As Long)
'=====================================
'SetAccessWindowOpacity() Version 1.0.
'------------------------------------------------------------------
' Author: © Copyright 2006 Pacific Database Pty Limited
' Graham R Seach (e-mail address removed)
'------------------------------------------------------------------
' Description: This function fades the Access application window's
' opacity to the specified value.
'
' Dependencies: Tested on Microsoft Access 2002/2003 only.
'
' Inputs: Opacity - Long value indicating the opacity level at which
' to set the fade (between 1 and 255).
'
' Outputs: None.
'=====================================
Dim hWndAccess As Long
Dim lOriginalStyle As Long

hWndAccess = Access.hWndAccessApp
lOriginalStyle = GetWindowLongPtr(hWndAccess, GWL_EXSTYLE)
SetWindowLongPtr hWndAccess, GWL_EXSTYLE, lOriginalStyle Or WS_EX_LAYERED

SetLayeredWindowAttributes hWndAccess, 0, CByte(Opacity), LWA_ALPHA
DoEvents
End Sub
---------<
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top