Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

API: Suppress the "Loading Image" dialog

Author(s)
Dev Ashish
Tom Wickerath

 

(Q) Instead of storing the images in a table, I'm now storing the path and filename of the files in a table, and using the Image control. However, I don't want the "Loading Image" dialog to come up. How can I hide this dialog?

(A) The "Loading Image" dialog is popped up by the filter that's processing the image. We don't have any direct control over it.

    There are two ways to prevent the dialog from coming up.

  1. By changing a registry setting emailed to me by Klaus Oberdalhoff.

      HKEY_LOCAL_MACHINE\Software\Microsoft\ Shared Tools\Graphics Filters\Import\JPEG\Options

    Change the ShowProgressDialog key value to "No".

   B. If you have multiple accounts, you must add the registry key to each separate account or to HKEY_CURRENT_USER.

 This registry file, from Tom Wickerath, changes the value of the ShowProgressDialog key to No for the following file types:
 
      BMP, GIF, JPEG, PCD, PCX, PICT, PNG, and TIFF in the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER branches.
 
      NOTE: this change will affect all Office programs, not just Access.

   C. Using the technique in the article Suppress the "Printing" Dialog, we can hide this dialog moments after it comes up.

    Call this subroutine from the OnTimer event of the form (with the TimerInterval set to a small number, say 200).

Private Sub Form_Timer()
  Call sHideLoadingImageDialog(hWndAccessApp)
End Sub
'************* 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 ***************

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer