Basic 7.0/7.1 WindowDo Does Not Trap Click in Current Window

This article was previously published under Q57853
This article has been archived. It is offered "as is" and will no longer be updated.
SUMMARY
The WindowDo procedure of the WINDOW.BAS toolbox file that is includedwith Microsoft Basic Professional Development System (PDS) versions7.0 and 7.1 for MS-DOS will not trap a click in the current windowunless that click is in a button or edit field.

To work around this limitation, open an "area" button (button type 4)in the current window that is exactly the same size as the currentwindow. This does not make the WindowDo procedure trap clicks in thecurrent window (it is only trapping a click in a button), but itappears so because an area button is invisible.
MORE INFORMATION
The WindowDo procedure allows you to trap window events such asselecting buttons and edit fields, resizing, moving, or closing awindow, and selecting a window other than the current window. However,WindowDo cannot trap a click in the current window itself unless theclick occurs on a button or edit field in that window.

For example, suppose a program opens two windows. For simplicity,assume there are no buttons or edit fields opened in either window. Bydefault, the last window opened (window2) is the current window. TheWindowDo procedure will trap a click in the other window (window1) butnot in window2. This is a design limitation of the WindowDo procedureand is not considered a problem.

To easily work around this situation, in the current window, open anarea button (button type 4) that is exactly the same size as thecurrent window. The WindowDo procedure is still trapping a click in abutton, but it appears as if a click is being trapped anywhere in thewindow because the button is hidden. Type 4 buttons are invisible.

For a detailed explanation of the WindowDo procedure, see page 572 ofthe "Microsoft Basic Version 7.0: Language Reference" versions 7.0 and7.1 manual. For more information on area buttons (button type 4), seethe ButtonOpen procedure on page 557 of the same manual.

The following example program illustrates the limitation and itsworkaround:

Example

'$INCLUDE: 'general.bi'   'These INCLUDE, COMMON SHARED, and DIM'$INCLUDE: 'mouse.bi'     'statements are generally those needed'$INCLUDE: 'menu.bi'      'for using the User Interface Toolbox.'$INCLUDE: 'window.bi'COMMON SHARED /uitools/ GloMenu           AS MenuMiscTypeCOMMON SHARED /uitools/ GloTitle()        AS MenuTitleTypeCOMMON SHARED /uitools/ GloItem()         AS MenuItemTypeCOMMON SHARED /uitools/ GloWindow()       AS WindowTypeCOMMON SHARED /uitools/ GloButton()       AS ButtonTypeCOMMON SHARED /uitools/ GloEdit()         AS EditFieldTypeCOMMON SHARED /uitools/ GloStorage        AS WindowStorageTypeCOMMON SHARED /uitools/ GloWindowStack()  AS INTEGERCOMMON SHARED /uitools/ GloBuffer$()DIM GloTitle(MAXMENU)           AS MenuTitleTypeDIM GloItem(MAXMENU, MAXITEM)   AS MenuItemTypeDIM GloWindow(MAXWINDOW)        AS WindowTypeDIM GloButton(MAXBUTTON)        AS ButtonTypeDIM GloEdit(MAXEDITFIELD)       AS EditFieldTypeDIM GloWindowStack(MAXWINDOW)   AS INTEGERDIM GloBuffer$(MAXWINDOW + 1, 2)CLSCALL WindowInit   'Initialize window and mouse routines.CALL MouseInit'Open window1. It is the current window..CALL WindowOpen(1, 4, 20, 20, 36, 14, 1, 14, 1, 15, FALSE, FALSE,_                FALSE, FALSE, 1, "Window 1")'Open window2, it is now the current window.CALL WindowOpen(2, 4, 45, 20, 61, 14, 1, 14, 1, 15, FALSE, FALSE,_                FALSE, FALSE, 1, "Window 2")CALL MouseShow        'Show the mouse cursor.CALL WindowDo(0, 0)   'Wait for a window event to happen.                      'The program will not continue until window1 is                      'clicked. This is because clicking in window2                      '(the current window) is not trapped by the                      'WindowDo procedure.'Assume window1 is the current window now.'Open an area button in the current window that is the same size as'the current window.CALL ButtonOpen(1, 0, "", 1, 1, 17, 17, 4)CALL WindowDo(0, 0)   'Wait for a window event to happen.                      'The program will continue if either window is                      'clicked. Clicking window2 will be trapped                      'because it is not the current window. Clicking                      'window1 will be trapped because there is a                      'button (although invisible) in window1 that                      'is the same size as window1.				
BasicCom 7.00 7.10
Properties

Article ID: 57853 - Last Review: 08/23/2013 17:30:24 - Revision: 3.1

  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1
  • kbnosurvey kbarchive KB57853
Feedback