How to set up a child window inside a main window

How to set up a child window inside a main window

Postby Silvio.Falconi » Fri Nov 11, 2022 9:31 am

By creating a main window (Mdi) under the conditions of the topic Logo in Mdi https://forums.fivetechsupport.com/viewtopic.php?f=3&t=39821&sid=6ac843679145a6baa3940eb9fa999c55

Image

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
#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

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: How to set up a child window inside a main window

Postby nageswaragunupudi » Fri Nov 11, 2022 10:22 am

Activate the mdi child window using

ACTIVATE oChildWnd MAXIMIZED
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to set up a child window inside a main window

Postby Antonio Linares » Fri Nov 11, 2022 11:22 am

Dear Silvio,

Even if you modify the size of oWndClient, the child windows will exceed its area, it is the way Windows is designed.

You may try to use oWndChild:aMinMaxInfo to restrict the child dimensions
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to set up a child window inside a main window

Postby Silvio.Falconi » Fri Nov 11, 2022 11:22 am

nageswaragunupudi wrote:Activate the mdi child window using

ACTIVATE oChildWnd MAXIMIZED


Also I put MAXIMIZED Not resolved!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: How to set up a child window inside a main window

Postby Silvio.Falconi » Fri Nov 11, 2022 11:25 am

Antonio Linares wrote:Dear Silvio,

Even if you modify the size of oWndClient, the child windows will exceed its area, it is the way Windows is designed.

You may try to use oWndChild:aMinMaxInfo to restrict the child dimensions




ok But for a sample If I move on left and on top I can set the position of child wnd

Code: Select all  Expand view
 if ::oWinTest:nLeft < 1
               ::oWinTest:Move(::oWinTest:nTop, 10 )    //ok
            Endif

          if  ::oWinTest:nTop < 2
               ::oWinTest:Move( 4, ::oWinTest:nLeft )  //ok
            Endif


this code run ok


I also intend to fix the position of the child window even when it is under the oBarRight
when this is visible or when the child window is beyond the width of the main window
in both cases the child window must be positioned just before
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: How to set up a child window inside a main window

Postby Silvio.Falconi » Fri Nov 11, 2022 12:53 pm

for now I resolved with this :

Image




Code: Select all  Expand view
#include "FiveWin.ch"

  #define colore1  nRgb( 245,244,234)  //sfondo dialog
  #define colore2  nRgb(233,229,206)


static oBarRight,oBarraBtn

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 "c:\work\fwh\bitmaps\client.bmp"  OF oBar NOBORDER GROUP ;
   ACTION TTestWndChild():New(oWnd):Activar(oWnd)

   DEFINE BUTTON oBarraBtn FILENAME "chiudi.bmp"   OF oBar NOBORDER  BTNRIGHT ;
   ACTION MostraBarra(oBarRight,oWnd)



   DEFINE BUTTONBAR oBarRight OF oWnd SIZE 230,32 2013 RIGHT
   oWnd:oRight:= oBarRight

   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)

     If oBarRight:lVisible()
         oBarraBtn:Disable()
      Endif

   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()
       if Len(oWnd:oWndClient:aWnd ) > 0
          oWnd:Tile()
       Endif
         oBarraBtn:Disable()
   return nil

Function CloseBarra(oWnd,oBarRight)
    oBarRight:Hide()
    oBarRight:nWidth:=1
    UpdateWindow( oWnd:hWnd )
   oWnd:CoorsUpdate()
    oWnd:oRight:=NIL
    oWnd:resize()
    SysRefresh()
     if Len(oWnd:oWndClient:aWnd ) > 0
          oWnd:Cascade()
       Endif
    oBarraBtn:Enable()
     Return nil





//---------------------------------------------------------------------//

 //small Class to open a child

  CLASS TTestWndChild
   DATA oWinTest
   DATA oBar
   Data oLbx
   Data oDbf

   METHOD New(oWndMain) CONSTRUCTOR
   METHOD Activar()

   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 Len( oWndMain:oWndClient:aWnd ) > 0
      if ( nRow + nHChild ) > oWndMain:nHeight
         nRow  := 0
         if ( nCol + Int( nWChild / 2 ) ) > oWndMain:nWidth
            nCol := 0
         else
            nCol += Int( nWChild / 2 )
         endif
      else
         nRow  += Int( nHChild / 4 )
      endif
   endif

 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 MAXIMIZED;
     VALID     (::oWinTest:=Nil,.T.)

RETURN NIL
//------------------------------------------------------------------//

//------------------------------------------------------------------/
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: How to set up a child window inside a main window

Postby Antonio Linares » Fri Nov 11, 2022 4:44 pm

Dear Silvio,

very good :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 93 guests