BBC BASIC for Windows
Programming >> BBC BASIC language >> Closing Dialog Boxes
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1411894468

Closing Dialog Boxes
Post by Matt on Sep 28th, 2014, 08:54am

Hi,

According to most help facilities, the normal way to close a dialog box routine is something like:

Code:
      ...
      UNTIL click% = 2 OR !dlg% = 0
      IF !dlg% <> 0 THEN PROC_closedialog(dlg%) 

When either the exit cross (top-right corner) or the 'Close' button is clicked upon, click% receives a close notification (2). (Although, you can catch the 'Close' before exiting the dialog box.) Either way, !dlg% retains the original pointer.

What is the reason for adding the '... OR !dlg% = 0' and the following 'IF !dlg% <> 0 THEN...'. Missing these out seems to have the same effect, so I'm guessing there's a good reason for them being advised.

Matt
Re: Closing Dialog Boxes
Post by rtr2 on Sep 28th, 2014, 09:30am

on Sep 28th, 2014, 08:54am, Matt wrote:
Either way, !dlg% retains the original pointer.

My tests suggest otherwise. Please perform these steps exactly:
  1. Load the supplied DLGDEMO.BBC program (in the EXAMPLES\WINDOWS folder).

  2. Add the following statement immediately after the UNTIL click%=1 OR click%=2 OR !dlg%=0 line:
    Code:
          PRINT !dlg% 

  3. Run the program (ignore the warning) and close the dialogue box by clicking on the corner X, or by pressing Escape.
When I do this what gets printed is zero, which contradicts your assertion that !dlg% retains the original handle.

I am puzzled if you are seeing something different, unless of course you're using a different library, such as WINLIB2B which is specifically documented as behaving differently in this respect: "WINLIB2B also suppresses the automatic closing of the dialogue box when you click on its close button, or press Escape":

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#winlib2

Richard.
Re: Closing Dialog Boxes
Post by Matt on Sep 28th, 2014, 3:34pm

on Sep 28th, 2014, 09:30am, g4bau wrote:
I am puzzled if you are seeing something different, unless of course you're using a different library, such as WINLIB2B which is specifically documented as behaving differently in this respect: "WINLIB2B also suppresses the automatic closing of the dialogue box when you click on its close button, or press Escape":

I'm actually using WINLIB2A. I can't remember why I started using it over WINLIB2, but I've been using it for ages. What are the differences, advantages and disadvantages of this one and others, which also have variants (which whould you suggest I normally use.)

Matt
Re: Closing Dialog Boxes
Post by rtr2 on Sep 28th, 2014, 5:29pm

on Sep 28th, 2014, 3:34pm, Matt wrote:
I'm actually using WINLIB2A. I can't remember why I started using it over WINLIB2, but I've been using it for ages. What are the differences, advantages and disadvantages of this one and others

The only documented versions are WINLIB2.BBC, WINLIB2B.BBC and WINLIB2U.BBC; the differences are described in the manual. As far as WINLIB2A is concerned I cannot remember how that differs; my inclination would be to suggest that it isn't used.

Richard.
Re: Closing Dialog Boxes
Post by Matt on Sep 28th, 2014, 8:07pm

OK. Fair enough.

Matt
Re: Closing Dialog Boxes
Post by Matt on Sep 29th, 2014, 07:12am

I recently reinstalled my desktop, including BB4W. I installed version 5.8 full and upgraded to 5.95. I've just checked and WINLIB2A is there. I've been using it for some time, so I assume, then, that it was shipped with 5.8.

This is not an important matter, as your suggestion that I should probably use WINLIB2 instead, will be used. But as you seemed to be unaware of the differences, I thought you might be interested.

Matt
Re: Closing Dialog Boxes
Post by rtr2 on Sep 29th, 2014, 08:48am

on Sep 29th, 2014, 07:12am, Matt wrote:
I've just checked and WINLIB2A is there.

Of course I am aware that WINLIB2A was distributed with BB4W, and it continues to be. Generally I never delete things from the distribution, even if they become obsolete (assuming they still work). But it's undocumented and I can't remember what the differences are (I have a suspicion that maybe it was designing to support context-sensitive help before *SYS 1 was introduced).

Richard.
Re: Closing Dialog Boxes
Post by rtr2 on Sep 29th, 2014, 11:32am

on Sep 29th, 2014, 08:48am, g4bau wrote:
I have a suspicion that maybe it was designed to support context-sensitive help before *SYS 1 was introduced

I can confirm that. Before the introduction of *SYS 1 there was no way to intercept and respond to WM_HELP messages received from a dialogue box. Accordingly, WINLIB2A converts them into WM_COMMAND messages with a special ID value (999), which can be handled by a regular ON SYS.

*SYS 1 makes that kludge obsolete, because WM_HELP messages can now be intercepted directly. Therefore on the introduction of that command WINLIB2A was replaced by WINLIB2B (which forwards WM_HELP messages to the parent window). However on the basis that some programs might still be using WINLIB2A it remained in the BB4W distribution.

WINLIB2A is now undocumented and ought not to be used in new programs. Existing programs which use it can continue to do so, at your own risk, so long as they work as required.

Richard.