Greetings! My situation is this. I currently have a database of
which in a form displays jpeg pictures (one at a time) which are
linked to the db and stored in a separate folder. I have set up a
report with an image control do display/print 4 pictures on a page.
When the report opens (in preview mode) the "loading image" dialog
flashes 4 times (once for each picture) which isn't a huge deal, but
is annoying.
There have been several posts in the past regarding suppressing this
dialog in relation to printing. The two approaches seem to be
modifying the registry and applying a technique from Dev Ashish at
http://www.mvps.org/access/api/api0037.htm.
My questions are this:
1. Is there some type of code floating around that can automate the
registry change?
(I need to deploy the front end database on 5 pc's and a.) I'm not
totally comfortable changing the registry and b.) I don't think I want
to go changing the registry on machines manually anyway.) Also, I
have tried this solution on my machine and it does work if you change
both the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER registry keys.
2. I have tried unsuccessfully to implement Dev's solution to no
avail. I think I am struggling with exactly where to place the
following portion of his code example:
************* Code Start *************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetClassName Lib "user32" _
Alias "GetClassNameA" _
(ByVal hWnd As Long, _
ByVal lpClassname As String, _
ByVal nMaxCount As Long) _
As Long
Private Declare Function apiGetWindowText Lib "user32" _
Alias "GetWindowTextA" _
(ByVal hWnd As Long, _
ByVal lpString As String, _
ByVal aint As Long) _
As Long
Private Declare Function apiGetLastActivePopup Lib "user32" _
Alias "GetLastActivePopup" _
(ByVal hWndOwnder As Long) _
As Long
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" _
(ByVal hWnd As Long, _
ByVal nCmdShow As Long) _
As Long
Private Const MAX_LEN = 255
Private Const GW_HWNDNEXT = 2
Private Const SW_HIDE = 0
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWDEFAULT = 10
Sub sHideLoadingImageDialog(ByVal hWndApp As Long)
'Required: hWndAccessApp (Application handle)
'
On Error GoTo Err_Handler
Dim lnghWndChild As Long
Dim strCaption As String
Dim strClass As String
Dim lngRet As Long
'Get the last active popup in hWndApp instance
lnghWndChild = apiGetLastActivePopup(hWndApp)
strClass = fGetClassName(lnghWndChild)
strCaption = fGetCaption(lnghWndChild)
'is this the modal window?
If strClass = "#32770" And Trim(strCaption) = vbNullString Then
lngRet = apiShowWindow(lnghWndChild, SW_HIDE)
End If
Exit_Here:
Exit Sub
Err_Handler:
MsgBox "Error #: " & Err.Number & vbCrLf & Err.Description, _
vbCritical + vbOKOnly, "sHideLoadingImageDialog-Runtime Error"
Resume Exit_Here
End Sub
Private Function fGetClassName(ByVal hWnd As Long) As String
Dim strBuffer As String
Dim lngRet As Long
strBuffer = String$(32, 0)
lngRet = apiGetClassName(hWnd, strBuffer, Len(strBuffer))
If lngRet 0 Then
fGetClassName = Left$(strBuffer, lngRet)
End If
End Function
Private Function fGetCaption(ByVal hWnd As Long) As String
Dim strBuffer As String
Dim lngRet As Long
strBuffer = String$(MAX_LEN, 0)
lngRet = apiGetWindowText(hWnd, strBuffer, Len(strBuffer))
If lngRet 0 Then
fGetCaption = Left$(strBuffer, lngRet)
End If
End Function
'************ Code End ***************
I would greatly appreciate any pointers and thanks in advance for your
time.
Brian