Dialog(0) Returns a 4 After All Windows Closed in UI Toolbox (73696)



The information in this article applies to:

  • Microsoft Basic Professional Development System for MS-DOS 7.0
  • Microsoft Basic Professional Development System for MS-DOS 7.1

This article was previously published under Q73696

SYMPTOMS

After the last open window (created using calls to the User Interface Toolbox) is closed, the Dialog(0) function continues to return a 4, meaning "Current window's close box was selected," when it should return a 0, which means "No event took place."

STATUS

Microsoft has confirmed this to be a bug in the User Interface (UI) Toolbox provided with Microsoft Basic Professional Development System (PDS) for MS-DOS, versions 7.0 and 7.1. A correction to this problem is provided below.

MORE INFORMATION

In the UI Toolbox, after the last open window is closed, the Dialog(0) function returns a 4. In this situation, Dialog(0) should actually return a 0.

The problem is in the WindowDo subprogram of WINDOW.BAS. When the last window is closed, the next call to WindowDo checks to see if there are any open windows. If there are no open windows, it executes an EXIT SUB statement when it actually needs to set the variable GloStorage.oldDialogEvent equal to 0.

The following code needs to be changed to correct the problem. It is located inside the WindowDo subprogram of WINDOW.BAS under the 'WindowDoInit' line label.

Change the following:
     IF windo = 0 THEN EXIT SUB
				
to the following:
     IF windo = 0 THEN
          GloStorage.oldDialogEvent = 0
          EXIT SUB
     END IF
				
The following sample program demonstrates the problem. When run with the uncorrected WindowDo, the Dialog Function always returns a 4 after the window is closed.

To run the program inside of the QBX.EXE environment, you must load the Quick library UIASM.QLB. Below is an example of using LINK.EXE from the MS-DOS command line to create UIASM.QLB:
     link /q uiasm + qbx.lib, uiasm.qlb,, qbxqlb;
				
Start QBX.EXE with the /l option to load the Quick library:
     qbx /l uiasm
				
From the File menu, choose Load File and load the source modules GENERAL.BAS, MOUSE.BAS, MENU.BAS, WINDOW.BAS into the QBX.EXE environment. Enter the sample program UISAMPLE.BAS listed below.

UISAMPLE.BAS

'$INCLUDE: 'general.bi'
'$INCLUDE: 'mouse.bi'
'$INCLUDE: 'menu.bi'
'$INCLUDE: 'window.bi'

COMMON SHARED /uitools/ GloMenu           AS MenuMiscType
COMMON SHARED /uitools/ GloTitle()        AS MenuTitleType
COMMON SHARED /uitools/ GloItem()         AS MenuItemType
COMMON SHARED /uitools/ GloWindow()       AS windowType
COMMON SHARED /uitools/ GloButton()       AS buttonType
COMMON SHARED /uitools/ GloEdit()         AS EditFieldType
COMMON SHARED /uitools/ GloStorage        AS WindowStorageType
COMMON SHARED /uitools/ GloWindowStack()  AS INTEGER
COMMON SHARED /uitools/ GloBuffer$()

DIM GloTitle(MAXMENU)           AS MenuTitleType
DIM GloItem(MAXMENU, MAXITEM)   AS MenuItemType
DIM GloWindow(MAXWINDOW)        AS windowType
DIM GloButton(MAXBUTTON)        AS buttonType
DIM GloEdit(MAXEDITFIELD)       AS EditFieldType
DIM GloWindowStack(MAXWINDOW)   AS INTEGER
DIM GloBuffer$(MAXWINDOW + 1, 2)

CLS
 MenuInit
 WindowInit
 MouseShow

 WindowOpen 1, 10, 10, 20, 70, 0, 7, 0, 7, 14,_

            TRUE, TRUE, FALSE, TRUE, 1, "CLOSE ME"

 ExitFlag = FALSE
 WindowSetCurrent 1
 WHILE NOT ExitFlag

        WindowDo 0, 0
        x = Dialog(0)
        LOCATE 24, 50: PRINT "Dialog(0) = "; x;
        SELECT CASE x
                CASE 4          ' Close the open window.
                        WindowClose 1
                CASE 9          ' Escape key hit, exit loop.
                        ExitFlag = TRUE
                CASE ELSE
        END SELECT

 WEND
 END
				
Note that the underscore character (_) shown above indicates line continuation, and should not be included as part of the program when entered into the QBX.EXE environment.

For more information on the UI Toolbox, query the Microsoft Knowledge Base on the following words:

UI and TOOLBOX and Basic


Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB73696