When is a window closed in TV? 
Author Message
 When is a window closed in TV?

I stuck with a little problem. I am using TP 6.0 and its Turbo Vision.
Here is the problem:
1) A dialog pops up
2) After the dialog closes a editor window (as in editors.tpu) pops up
3) Another window (editor or just view wimdow - scrollable text) pops up

4) When both of 2) & 3) windows are closed another dialog is poped up
5) Like in 2)
6) like in 3)

etc.

So how do I accomplish the step 4) i.e. how do I know when are both windows
closed? Is there a list of IDs for every TView? Is there a list of active
TViews? Are there any flags for active windows? How do I close a specific
window from the program?

                                                        Denis



Wed, 18 Jun 1902 08:00:00 GMT  
 When is a window closed in TV?

Quote:

> I stuck with a little problem. I am using TP 6.0 and its Turbo Vision.
> Here is the problem:
> 1) A dialog pops up
> 2) After the dialog closes a editor window (as in editors.tpu) pops up
> 3) Another window (editor or just view wimdow - scrollable text) pops up

> 4) When both of 2) & 3) windows are closed another dialog is poped up
> 5) Like in 2)
> 6) like in 3)

> etc.

> So how do I accomplish the step 4) i.e. how do I know when are both windows
> closed? Is there a list of IDs for every TView? Is there a list of active
> TViews? Are there any flags for active windows? How do I close a specific
> window from the program?

>                                                         Denis

I take it you want to trigger step 4 when both of the previous windows
have closed, whichever order they closed in.

TV Windows do not have ID's, nor is there a separate window list.  They
exist as a chain of heap pointers starting at the desktop (or the owning
views) "Last" pointer.

An event-based way, would be to put a handleevent trap in both of the 2)
and 3) dialog box types, ie:

procedure Txxxxx.HandleEvent;
begin
  inherited HandleEvent(Event):

  if (Event.What = evBroadCast) and (Event.Command=cmAreYouThere) then
     ClearEvent(Event);
end;

And add to the done procedure:

destructor Txxxx.Done;
var P : pointer;
begin
  P := Message(Desktop, evBroadCast, cmAreYouThere, nil);
  if P=nil then begin
    {create new box}
  end;
  inherited Done;
end;

Something like that anyway.  It works by sending a message around the
desktop, the event being cleared if one of the boxes 2/3 are there to
trap it and clear it.  A cleared message (ie boxes exist) will return a
non-nil to P.  So only if there isn't another box will this one create
your new one.

You'll need to define a new cmAreYouThere constant (or two of them
maybe, one for each of the boxes 2) and 3)).  Make sure the windows'
eventmasks are set to trap broadcast events.

You might also have it so that on closing, the windows send a message
around the desktop saying that it's closing, and the other window traps
this and keeps that fact (in a flag or something), so it knows that when
it closes it has to create the new dialog box.

Hope this helps...

--
Martin
------------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 When is a window closed in TV?

Quote:

>... how do I know when are both windows closed?
>Is there a list of IDs for every TView? Is there a list of active
>TViews? Are there any flags for active windows? How do I close a
>specific window from the program?

To know when all windows are closed, you can override the
idle method of your application and use something based on
the following:

PROCEDURE tApp.Idle;
{ ===================================================== }
VAR Event:tEvent;

    FUNCTION isSelectable(p: pView): Boolean; FAR;
    { ------------------------------------------------- }
    Begin
        isSelectable := (p^.Options and ofSelectable <> 0)
                        and (p^.State and sfVisible <> 0);
    End;

BEGIN
    tApplication^.Idle;

    { other actions... }
    Clock^.Update;
    Heap^.Update;

    If (Current = Pointer(Desktop))


    Then Begin
       { stuff a "cmMenu" Command when doing nothing Else }
       Message(Application, evCommand, cmMenu, NIL);
    End;
END;

Rather than send a message to select the menu bar you could
launch your default window.

    ...red



Wed, 18 Jun 1902 08:00:00 GMT  
 When is a window closed in TV?

I found the solution combinig the two solutions in followups. If anyone
is interested in solution mail me.

                                                Denis



Wed, 18 Jun 1902 08:00:00 GMT  
 When is a window closed in TV?

Quote:

>I found the solution combinig the two solutions in followups. If anyone
>is interested in solution mail me.

I'm glad you solved the problem.  I've been a little busy
and haven't been able to spend much time looking into the
problems you described in the email you sent.  

I'd like to pass on some tips on how I handle TV windows.
I started by assigning each window a unique window number so
that I could send broadcast messages to find them.  

I have since reworked twindow to contain both a FrameNo (old
tv number), and a Number.  FrameNo values of 1..9 display in
the frame, Number is assigned a unique value based on its
purpose.  In some apps this may be a record number.

I beefed up twindow select commands to include
  cmSelectWindowNum   =  55;
  cmSelectFrameNo     =  57;
  cmWindowAddress     =  99;
  cmBuildWindowList   = 298;
  cmWList             =  98;
  cmFrameNumbers      =  97;

I beefed up twindow's HandleEvent to include:

   if (Event.What = evBroadcast) Then
      Case Event.Command of
         cmWindowAddress:
             If (Event.InfoWord = Number) Then
                ClearEvent(Event);

         cmFrameNumbers:
             If FrameNo < 16 Then
                Word(Event.InfoPtr^) :=
                   Word(Event.InfoPtr^) or (1 shl FrameNo );

         cmSelectWindowNum:
             If  (Event.InfoWord = Number)
             and (Options and ofSelectable <> 0) then
             begin
                Select;
                ClearEvent(Event);
             End;

         cmSelectFrameNo:
             If  (FrameNo <> 0)
             and (Event.InfoInt = FrameNo)
             and (Options and ofSelectable <> 0) then
             begin
                Select;
                ClearEvent(Event);
             End;

         cmBuildWindowList:
             If  (Trim(GetTitle(80)) <> '')
             and GetState(sfVisible) Then
                With pCollection(Event.InfoPtr)^ Do

      End{Case};

Hope you find some of this useful.

    ...red



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. TV: Close all windows

2. closing a Window with Pascal for Windows

3. DOS in a TV window using TP7?

4. I am Looking for TP under windows

5. I Am Interested in Pascal for Windows

6. Closing windows when executing another pascal program win1.5

7. Close a window using the onclose-event

8. Newbie: Saving DB info when windows closes!!

9. Maximized MDI child windows - close/system buttons vanishes in thin air

10. Detect if file is closed on BP7 (Dos or Windows)

11. Detect if file is closed on BP7 (Dos or Windows)

12. Table.Close does not close file handle?

 

 
Powered by phpBB® Forum Software