FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Closing Windows neatly
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM
Closing Windows neatly
Posted: Fri Jan 05, 2007 09:36 AM

I have a MDI application that opens different databases, say CLIENTS, SUPPLIERS and MANUFACTURERS.

I open each as a MDICHILD. (I use resources, so I have a borderless dialog the same size of the MDICHILD) (as taught to be my Antonio Linares and fwh\samples\TestMdi4.prg )

  1. I want to prevent the user from opening the same table more than once, so I need to check before opening, if the window is defined - ISWINDOW() doesn't seem to be working - is it me? Is that correct way?

2.I've also tried checking if the table is already open - if it is, the user has opened the window before. (in this case I want to bring that window 'to the front'. I need a oWnd:Maximize() function like the oWnd:Restore() to do this?
(I tried: wndMain():oWndClient:aWnd[1]:setFocus() as suggested by James Bott on this forum - but this only brings the window to the front, not maximise it if it is restored.)

  1. The problem with using the check in (2.) above, is that if the user doesn't press my "CLOSE NEATLY" button, I don't get to check that the last data was saved and that the databases get closed. (e.g. they press the 'X' on the window to close. ) Is the VALID clause where this needs to happen?

  2. If the VALID clause is the correct place, do I put it on the (borderless) oDLG or on the oMDICHILDWnd ? All I can get it to do is to either close the whole app, or close without 'neatening up' first.

Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM
Closing Windows neatly
Posted: Fri Jan 05, 2007 09:39 AM

I answered 2. myself: wndMain():oWndClient:aWnd[1]:MAXIMIZE()
(thanks to James Bott's 'bring window to the front')

Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Closing Windows neatly
Posted: Fri Jan 05, 2007 10:05 AM

Ollie,

Better check if the table is already in use, and/or disable the menuitems and buttons to reopen a window meanwhile it is open

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 97
Joined: Mon Nov 21, 2005 10:29 AM
Re: Closing Windows neatly
Posted: Fri Jan 05, 2007 01:25 PM
Ollie wrote:I have a MDI application that opens different databases, say CLIENTS, SUPPLIERS and MANUFACTURERS.

I open each as a MDICHILD. (I use resources, so I have a borderless dialog the same size of the MDICHILD) (as taught to be my Antonio Linares and fwh\samples\TestMdi4.prg )


1. I want to prevent the user from opening the same table more than once, so I need to check before opening, if the window is defined - ISWINDOW() doesn't seem to be working - is it me? Is that correct way?

Hi,
I use tis code to check if window with the same title is already opened:

for i := 1 to len(oWnd:oWndclient:aWnd)
if 'MDICHILD'$oWnd:oWndclient:aWnd[i]:classname()
jcaption:=alltrim(oWnd:oWndclient:aWnd[i]:cCaption)
if jcaption==alltrim(newcaption) //Alreadyhave MDI child with this name
oWnd:oWndclient:aWnd[i]:Setfocus()
return


endif
endif
next
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM
Closing Windows neatly
Posted: Fri Jan 05, 2007 09:52 PM

Thanks Taavi, I'll give it a try.

Antonio - how can I be sure that the databases are closed no matter how the user closes the screen.

E.g. If he presses the 'close' button, I check that the data is saved and that the tables are closed.

If he presses the Child 'X' to close or the Application 'X' to close - the checks don't get done.

Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)
Posts: 189
Joined: Mon Nov 07, 2005 07:36 PM
Closing Windows neatly
Posted: Sat Jan 06, 2007 01:54 PM

I use a static variable then when i come in i set the var in "9999" and later if try to in one more time i see if the var is set to NIL or <> NIL
then when i finish restart de var to NIL .....
that's my way !!

Julio Gonzalez V.

RANDOM S.A.

SISTEMICA S.A.
Posts: 310
Joined: Sun Jan 08, 2006 10:09 PM
Closing Windows neatly
Posted: Sat Jan 06, 2007 03:06 PM
I have a same problem

I use this code:
#command OPEN <(db)>                                                    ;
             [VIA <rdd>]                                                ;
             [ALIAS <a>]                                                ;
             [<new: NEW>]                                               ;
             [<ex: EXCLUSIVE>]                                          ;
             [<sh: SHARED>]                                             ;
             [<ro: READONLY>]                                           ;
             [INDEX <(index1)> [, <(indexn)>]]                          ;
       => if Select( <(db)> )==0                                        ;
         ;      dbNetUseArea( <.new.>, <rdd>, <(db)>, <(a)>, if(<.sh.> .or. <.ex.>, !<.ex.>, NIL), <.ro.>, 0 )[; dbSetIndex( <(db)> )];
         ;else                                                          ;
         ;   dbSelectArea( <(db)> )                                     ;
         ;endif


In if Select( <(db)> ) you pass the table name and if is not in memory open or just select the open table.

...
if Select( "clients" )==0
   use CLIENTS shared new index ...
else
   dbSelectArea( "clients" )
endif
...

Continue the discussion