Anser,
Programmers that are converting DOS apps to Windows seem to always be enamored with the possibilities of MDI. However, it is it my opinion that MDI interfaces for databases are a poor design. MDI was invented for applications like word processing where all the windows are the same and are usually full screen.
The problem with using MDI in database applications is that every window is different and to have two visible at the same time is often difficult or impossible. Also, it usually requires a lot of manual manipulation by the user which is wasted effort.
If you are interested in more on this topic I suggest getting a copy of any of Alan Cooper's books "About Face The Essentials of User Interaction Design" (there are three editions).
If you still want to design MDI app, the information below may answer some of your questions. This is from my old notes. Use it at your own risk.
Regards,
James
-----------------------------------------------------
Checking for MDI child windows
If you need to check for MDI child windows you can look at oWnd:oWndClient:aWnd which is an array of MDI child windows objects.
You can check the captions:
- Code: Select all Expand view
oWnd:oWndClient:aWnd[1]:cCaption
Here is an example of counting the number of a certain type of MDI windows that are open.
- Code: Select all Expand view
function WndCount(cCaption)
local i:=0,nCount:=0,oWnd:=wndMain()
if valtype(oWnd:oWndClient:aWnd)!=nil
for i=1 to len(oWnd:oWndClient:aWnd)
if oWnd:oWndClient:aWnd[i]:cCaption = cCaption
nCount++
endif
next
endif
return nCount
Here is a function to prevent opening more than one copy of a MDI child window. It also brings the window to the top and set the focus to it.
- Code: Select all Expand view
//--- Sets focus to child MDI window with cTitle
static function wndSetFocus(cTitle)
local i:=0,lSuccess:=.f.
cTitle:=upper(cTitle)
for i=1 to len(wndMain():oWndClient:aWnd)
if upper( wndMain():oWndClient:aWnd[i]:cCaption )=cTitle
wndMain():oWndClient:aWnd[i]:setFocus()
lSuccess:=.t.
endif
next
return lSuccess
Then you can do something like this for a menu or button:
...ACTION if( ! wndSetFocus("Order"), TOrder():new():browse(),)