Closing Windows neatly

Closing Windows neatly

Postby Ollie » Fri Jan 05, 2007 9: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.)


3. 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?

4. 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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Ollie » Fri Jan 05, 2007 9: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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Closing Windows neatly

Postby Taavi » Fri Jan 05, 2007 1: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
Taavi
 
Posts: 89
Joined: Mon Nov 21, 2005 10:29 am

Postby Ollie » Fri Jan 05, 2007 9: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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby dbzap » Sat Jan 06, 2007 1: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.
User avatar
dbzap
 
Posts: 189
Joined: Mon Nov 07, 2005 7:36 pm
Location: Chile

Postby Rochinha » Sat Jan 06, 2007 3:06 pm

I have a same problem

I use this code:
Code: Select all  Expand view
#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.

Code: Select all  Expand view
...
if Select( "clients" )==0
   use CLIENTS shared new index ...
else
   dbSelectArea( "clients" )
endif
...
Rochinha
 
Posts: 310
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests