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.
Closing Windows neatly
Closing Windows neatly
Many thanks
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Closing Windows neatly
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:classname()
jcaption:=alltrim(oWnd:oWndclient:aWnd:cCaption)
if jcaption==alltrim(newcaption) //Alreadyhave MDI child with this name
oWnd:oWndclient:aWnd:Setfocus()
return
endif
endif
next
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.
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.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
I have a same problem
I use this code:
In if Select( <(db)> ) you pass the table name and if is not in memory open or just select the open table.
I use this code:
Code: Select all
#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
Code: Select all
...
if Select( "clients" )==0
use CLIENTS shared new index ...
else
dbSelectArea( "clients" )
endif
...