Antonio Linares wrote:Your solution looks fine. Why do you care about the coordinates ?
Because the position (together with Height and Width) are saved on closing, so when the MDICHILD opens again, it's openend on the same position on the screen as where it was last closed. Same goes for height and width.
Antonio Linares wrote:I would suggest to change the "virtual" MDICHILD position when its maximized, but besides that, it seems ok
But than the user still can move the window out of the MDI Parent window. But this is not the problem
These are the 3 things I would like the "virtual" MDICHILD to do, just like the "real MDICHILD" :
1. User can not move MDICHILD outside of the MDIParent (It's 'captured' in the MDIParent window)
(
That's OK with 'SetParent()')
2. Save MDICHILD's position together with its Height and Width
(
This is what does not work)
3. Count with oWndParent:aWnd if there are MDICHILD's open
(
Can we add the window manually to oWndParent:oWndClient:aWnd?)
Patrick
PS. I'm thinking.. Would it not be more simple to change MDI- and/or Window class so a real MDICHILD accepts its own menu?
PS2. This code shows the Cordination problems even more clear. The Top, Left, Width and Height vallues are shown in the Windows title bar:
- Code: Select all Expand view RUN
#include "fivewin.ch"
STATIC oWndParent
PROCEDURE Main
LOCAL oMenu
MENU oMenu
MENUITEM "Menu"
MENU
MENUITEM "New Regular window" ;
ACTION NewWindow2(.F.,"Regular window")
MENUITEM "New regular MDI Child window" ;
ACTION NewWindow1("Regular MDI Child window")
MENUITEM "New MDI Child window via Setparent()" ;
ACTION NewWindow2(.T.,"MDI Child window via Setparent()")
SEPARATOR
MENUITEM "Show Len(oWndParent:oWndClient:aWnd)" ;
ACTION MsgInfo( Len(oWndParent:oWndClient:aWnd) )
ENDMENU
ENDMENU
DEFINE WINDOW oWndParent ;
MENU oMenu ;
FROM 10,10 TO 50,99 ;
TITLE "Test MDI Child with Setparent()" ;
MDI
ACTIVATE WINDOW oWndParent
RETURN
//-------------------------------------------------------------//
PROCEDURE NewWindow1(cTitle)
LOCAL oWndChild
DEFINE WINDOW oWndChild;
MDICHILD;
OF oWndParent
ACTIVATE WINDOW oWndChild;
ON MOVE ShowCoordinates(oWndChild,cTitle) ;
ON RESIZE ShowCoordinates(oWndChild, cTitle) ;
ON PAINT ShowCoordinates(oWndChild, cTitle)
RETURN NIL
//-------------------------------------------------------------//
PROCEDURE NewWindow2(lMDIChild,cTitle)
LOCAL oWndChild,oMenu
MENU oMenu
MENUITEM "File"
MENU
MENUITEM "Show coordinates";
ACTION MsgInfo( ShowCoordinates(oWndChild, cTitle) )
ENDMENU
ENDMENU
DEFINE WINDOW oWndChild;
MENU oMenu
ACTIVATE WINDOW oWndChild;
ON MOVE ShowCoordinates(oWndChild, cTitle) ;
ON RESIZE ShowCoordinates(oWndChild, cTitle) ;
ON PAINT ShowCoordinates(oWndChild, cTitle)
IF lMDIChild
SetParent( oWndChild:hWnd, oWndParent:oWndClient:hWnd )
//Aadd( oWndParent:oWndClient:aWnd, oWndChild )
ENDIF
RETURN NIL
//-------------------------------------------------------------//
FUNCTION ShowCoordinates(oWndChild,cTitle)
LOCAL aStart, cPos, aClntArea
aClntArea:=GetClientRect(oWndParent:hWnd)
oWndChild:Normal()
aStart:={aClntArea[ 1],aClntArea[ 2]}
ClientToScreen(oWndParent:hWnd,aStart)
oWndChild:CoorsUpdate()
cPos:=LTrim(Str(oWndChild:nTop ,4,0))+","+;
LTrim(Str(oWndChild:nLeft ,4,0))+","+;
LTrim(Str(oWndChild:nBottom ,4,0))+","+;
LTrim(Str(oWndChild:nRight ,4,0))
oWndChild:SetText( cTitle + " [ " + cPos + " ]" )
RETURN cTitle + " [ " + cPos + " ]"
//-------------------------------------------------------------//