I wish to open a child window that does not go out of certain parameters
for the top margin I set - 10 for the left margin - 4 and it works fine.
I have difficulty with the bottom margin and the right margin.
For the bottom margin I would like the child window not to exceed the end of the main window
For the right margin I have to make a clarification:
- if the bar on the right (oBarRight) is visible, the child window must reach the beginning of the bar oBarRight as the left margin is positioned
- if the right bar (oBarRight) is not visible, the child window must be positioned at the end of the main window (-4) and must not go further
Is there anyone who is able to help me?
the test
- Code: Select all Expand view RUN
- #include "FiveWin.ch"
#define colore1 nRgb( 245,244,234) //sfondo dialog
#define colore2 nRgb(233,229,206)
static oBarRight
function Main()
local oWnd, oLogo,oBar,oFont
local nClrText := CLR_BLACK
lBarRight:=.t.
DEFINE FONT oFont NAME "TAHOMA" SIZE 0, 14
DEFINE WINDOW oWnd MDI ;
COLOR CLR_BLACK, CLR_WHITE ;
TITLE "Test logo in Mdi with two buttonars"
@ 0, 0 Bitmap oLogo File "c:\work\fwh\bitmaps\fivetech.bmp" of oWnd:oWndClient PIXEL NOBORDER
DEFINE BUTTONBAR oBar OF oWnd _3D 2015 //SIZE 40, 40
DEFINE BUTTON FILENAME "chiudi.bmp" OF oBar NOBORDER GROUP ;
ACTION MostraBarra(oBarRight,oWnd)
DEFINE BUTTON OF oBar NOBORDER GROUP ;
ACTION TTestWndChild(oWnd):New():Activar(oWnd)
DEFINE BUTTONBAR oBarRight OF oWnd SIZE 230,32 2013 RIGHT
oWnd:oWndClient:bPainted := { || SetLogo( oLogo,oWnd ), 1 }
oWnd:bResized := { || SetLogo( oLogo, oWnd ) }
SET MESSAGE OF oWnd TO "test" CENTER NOINSET 2015
Navigator(oBarRight,oWnd,oLogo)
oWnd:oRight:= oBarRight
ACTIVATE WINDOW oWnd
return nil
function SetLogo( oLogo, oWnd )
local nX, nY
nX := oWnd:oWndClient:nWidth() - oLogo:nWidth() - 10
nY := oWnd:oWndClient:nHeight() - oLogo:nHeight() - 10
oLogo:Move( nY, nX, oLogo:nWidth(), oLogo:nHeight(), .T. )
return nil
Function Navigator(oBarRight,oWnd,oLogo)
local oPanel1
DEFINE BUTTON FILENAME "apri.bmp" OF oBarRight NOBORDER GROUP ;
ACTION CloseBarra(oWnd,oBarRight)
Return nil
Function MostraBarra(oBarRight,oWnd)
oBarRight:nWidth:= 250
oBarRight:show()
UpdateWindow( oWnd:hWnd )
oWnd:CoorsUpdate()
oWnd:oRight:=oBarRight
oWnd:resize()
SysRefresh()
return nil
Function CloseBarra(oWnd,oBarRight)
oBarRight:Hide()
oBarRight:nWidth:=1
UpdateWindow( oWnd:hWnd )
oWnd:CoorsUpdate()
oWnd:oRight:=NIL
oWnd:resize()
SysRefresh()
Return nil
//---------------------------------------------------------------------//
//small Class to open a child
CLASS TTestWndChild
DATA oWinTest
DATA oBar
Data oLbx
Data oDbf
METHOD New(oWndMain) CONSTRUCTOR
METHOD Activar()
METHOD CheckChild()
END CLASS
//---------------------------------------------------------------------//
METHOD New(oWndMain) CLASS TTestWndChild
local oSelf:=self
local cOrder := ""
local oBtn
local oGet
local nRow:= 0,nCol:= 0
local nHChild := 24
local nWChild := 79
local nPosL := 0
local nPosVSp := 360 //331
local nHSay := 19
local nWPanel := 32
if ::oWinTest == nil
::oDbf:= TDatabase():Open( , "Customer", "DBFCDX", .T. )
::oDbf:setorder(1) //First
::oDbf:GoTop()
DEFINE WINDOW ::oWinTest MDICHILD ;
FROM nRow, nCol TO nHChild, nWChild ;
TITLE "Customers" ;
of oWndMain
DEFINE BUTTONBAR ::oBar TOP OF oWndMain 2015
@ 0,5 XBROWSE ::oLbx OF ::oWinTest ;
DATASOURCE ::oDbf AUTOCOLS ;
AUTOSORT ;
NOBORDER CELL LINES
::oLbx:CreateFromCode()
::oWinTest:oClient := ::oLbx
::oWinTest:oControl := ::oLbx
else
::oWinTest:SetFocus()
endif
RETURN Self
//-----------------------------------------------------------------//
METHOD Activar(oWndMain) CLASS TTestWndChild
local oSelf:=self
/* ACTIVATE WINDOW ::oWinTest ;
ON MOVE ( ::oWinTest:CoorsUpdate(), ;
if( ::oWinTest:nLeft < 1, ::oWinTest:Move(::oWinTest:nTop,10 ), ), ; //ok
if( ::oWinTest:nTop < 2, ::oWinTest:Move( 4, ::oWinTest:nLeft ), ) , ; //ok
if( ::oWinTest:nBottom > oWndMain:nBottom, ::oWinTest:Move( ::oWinTest:nTop, 4 ), ) , ;
if( ::oWinTest:nLeft > If(oBarRight:lVisible,;
(oBarRight:nbottom-::oWinTest:nWidth)+150,;
(oWndMain:nWidth-::oWinTest:nWidth)+100),;
::oWinTest:Move(::oWinTest:nTop,;
If(oBarRight:lVisible,;
(oBarRight:nbottom-::oWinTest:nWidth)+10,;
(oWndMain:nBottom-::oWinTest:nBottom) ) ) ) ;//ok
*/
ACTIVATE WINDOW ::oWinTest ;
ON MOVE ( ::oWinTest:CoorsUpdate(), ;
::CheckChild(oWndMain) ) ;
VALID (::oWinTest:=Nil,.T.)
RETURN NIL
//------------------------------------------------------------------//
Method CheckChild(oWndMain) CLASS TTestWndChild
if ::oWinTest:nLeft < 1
::oWinTest:Move(::oWinTest:nTop, 10 ) //ok
Endif
if ::oWinTest:nTop < 2
::oWinTest:Move( 4, ::oWinTest:nLeft ) //ok
Endif
//good
if ::oWinTest:nBottom > (oWndMain:nBottom-::oWinTest:ntop)
::oWinTest:Move( oWndMain:nBottom-::oWinTest:ntop, ::oWinTest:nLeft )
Endif
//nogood
if ::oWinTest:nLeft > If(oBarRight:lVisible,;
(oBarRight:nbottom-::oWinTest:nWidth)+150,;
(oWndMain:nWidth-::oWinTest:nWidth) +100)
::oWinTest:Move(::oWinTest:nTop,;
If(oBarRight:lVisible,;
(oBarRight:nbottom-::oWinTest:nWidth)+10,;
(oWndMain:nBottom-::oWinTest:nBottom) ) )
Endif
RETURN NIL
the child window can be activated by calling the TTestWndChild (oWnd): New (): Activar (oWnd) class
I have entered the control of the child window in the CheckChild(oWndMain) of the CLASS TTestWndChild
for the moment I solved it by inserting oWinmain: Tile () but it is not a satisfactory solution