FIX: CDatabase::Open Uses Wrong Handle for the Parent Window

ID: Q125730

1.50 WINDOWS kbother kbfixlist kbbuglist

The information in this article applies to:

SYMPTOMS

If an application calls CDatabase::Open and does not pass a data source name as the first argument, a dialog with a list of data sources is displayed. If the call to CDatabase::Open was made from a dialog box that is modal to the application's main window, the following incorrect behavior will be observed:

- Although the data source name dialog is modal, it is possible to activate

  the first dialog without first closing the data sources dialog.

- When the data source name dialog is closed, the application's main
  window is activated rather than the first dialog.

CAUSE

CDatabase::Open uses the wrong window handle for the parent window of the data source name dialog box.

RESOLUTION

Do not call CDatabase::Open to display a dialog box if there is an active popup window owned by the main application window.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ for Windows, version 1.51.

MORE INFORMATION

CDatabase::Open uses the handle associated with the main application window as the parent window handle passed to SQLDriverConnect. The handle will be not be the correct one if there are other active popup windows owned by the main application window. The correct window in that situation should be retrieved by calling GetLastActivePopup.

Additional reference words: 2.50 1.50 KBCategory: kbother kbfixlist kbbuglist KBSubcategory: MfcDatabase

Keywords          : kbDatabase kbMFC kbODBC kbVC kbbuglist kbfixlist
Version           : 1.50
Platform          : WINDOWS
Solution Type     : kbfix

Last Reviewed: September 20, 1997