ACC2: Application Hangs Using COMMDLG.DLL
ID: Q124903
|
The information in this article applies to:
SYMPTOMS
Advanced: Requires expert coding, interoperability, and multiuser skills.
An application stops responding (hangs) when you try to close it after the
application displays the common Open File dialog box from COMMDLG.DLL. For
example, the AreTablesAttached() function in the Solutions sample
application (SOLUTION.MDB) exhibits this behavior if you click anywhere
outside the "Where is NWIND?" common dialog box and then try to quit the
Solutions sample application or Microsoft Access without first closing the
common dialog box.
CAUSE
This problem occurs when you fail to set the hWnd member of the
OpenFileName structure passed to the GetOpenFileName() function in
COMMDLG.DLL.
RESOLUTION
Make sure that the parent window's handle is passed in the hWnd member of
the OpenFileName structure. If the proper handle is passed in the
structure, the common dialog box will be opened as a modal dialog box and
users will not be able to close the parent window without first closing the
common dialog box.
STATUS
Microsoft has confirmed this to be a problem in Microsoft Access
version 2.0. This problem no longer occurs in Microsoft Access
version 7.0.
MORE INFORMATION
Steps to Reproduce Problem
These steps assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools
provided with Microsoft Access. For more information on Access Basic,
please refer to the "Building Applications" manual.
WARNING: The following steps will cause Microsoft Access to hang, forcing
you to restart Windows. Make sure to save and close any open work on your
computer before following these steps.
- Rename the NWIND.MDB file in the ACCESS\SAMPAPPS subdirectory to
NWINDX.MDB.
- Start Microsoft Access and open the Solutions sample application
(SOLUTION.MDB).
- When the "Where is NWIND.MDB?" common dialog box is displayed, click
outside the dialog box and then choose Exit from the File menu.
Microsoft Access hangs.
- Press CTRL+ESC to open the Windows Task List. Select Microsoft
Access in the Task List, and then choose End Task.
- Quit and then restart Windows.
Steps to Correct Problem in SOLUTION.MDB
- Start Microsoft Access.
- From the File menu, choose Open Database.
- In the File Name box, select SOLUTION.MDB. Press down and hold the
SHIFT key while you choose the OK button.
- Add the following lines to the Declarations section of the
Reattach NWIND module.
NOTE: In the following sample code, an underscore (_) at the end of a
line is used as a line-continuation character. Remove the underscore
from the end of the line when re-creating this code in Access Basic.
Option Explicit
Declare Function MSA_FindWindow Lib "User" Alias "FindWindow" _
(ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
NOTE: You may have some Microsoft Windows API functions defined in an
existing Microsoft Access library; therefore, your declarations may be
duplicates. If you receive a duplicate procedure name error message,
remove or comment out the declarations statement in your code.
- Locate the GetMDBName() function in the Reattach NWIND module. Change
the line that reads
OFN.hwndOwner = 0
to read:
OFN.hwndOwner = MSA_FindWindow("OMain", 0&)
- Save the module and then close it. Close SOLUTION.MDB.
- Open SOLUTION.MDB. When the "Where is NWIND?" common dialog box
is displayed, note that you cannot click outside the common
dialog box. You cannot close SOLUTION.MDB or Microsoft Access
until you close the common dialog box.
REFERENCES
"Microsoft Windows 3.1 Programmer's Reference," Volume 1, Chapter 4,
"Common Dialog Box Library"
Keywords : kbusage DcmSltn
Version : 2.0
Platform : WINDOWS
Issue type : kbbug