Move controls as window size

Move controls as window size

Postby Marco Turco » Fri Feb 13, 2015 5:34 pm

Hi all,
I'm looking for the best way to move the controls in this folder (those in the red rectangule) automatically down based on the window size.
Which is in your opinion the best way to do it ? Instead of move any control, could it be possibile to put over the folder resource a large control (a title for example) and the put those controls over the title in order I can move all of them moving just the control under ?

Any ideas appreciated. thank you

Image
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Move controls as window size

Postby reinaldocrespo » Fri Feb 13, 2015 8:58 pm

I may have missed something, but it sounds like something I do often.

Here is some code to illustrate:

Code: Select all  Expand view

   LOCAL oSelf := SELF
...
   ACTIVATE WINDOW ::oWnd ;//MAXIMIZED;
           ON INIT ...
         ON RESIZE oSelf:SetSize( nSizeType, nWidth, nHeight ) ;
             VALID oSelf:End()
...

METHOD SetSize( nType, nWidth, nHeight ) CLASS MpCal
local nCntrl := aScan( ::oWnd:aControls, { |e| upper( e:ClassName() ) $ "TTOOLBAR,TREBAR,TBAR,TRIBBONBAR" } )
LOCAL aClient := GetClientRect ( ::oWnd:hWnd ), i

    if nWidth != nil

      if nCntrl > 0 .and. nHeight != Nil ; nHeight -= ::oWnd:aControls[ nCntrl ]:nHeight   ;endif

      ::oGridViewDlg:SetSize( aClient[4] - 1, nHeight, .T. )
      ::oGridViewDlg:Move( 0, 0 )
      ::oGridViewDlg:Show()
      ::oGridViewDlg:Refresh()

      IF ::oGridView == NIL
         RETURN NIL
      ENDIF

      ::oGridView:SetSize( ::oGridViewDlg:nWidth, ::oGridViewDlg:nHeight , .T. )
      ::oGridView:Move( 0, 0 )
      ::oGridView:SetFocus()


RETURN NIL

 


Perhaps that helps.

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Move controls as window size

Postby Marco Turco » Sat Feb 14, 2015 10:02 am

Ok, I understand. I will try, thank you.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Move controls as window size

Postby Antonio Linares » Sat Feb 14, 2015 10:20 am

Marco,

When there are only two controls, you can use oWnd:oClient and oWnd:oBottom (oWnd is any window or dialog. A folder page is a dialog).

But as you have several controls, you can do as Reinaldo has explained you or you can use FWH layouts.

Please search in FWH\samples for "layout" and check those examples :-)
regards, saludos

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

Re: Move controls as window size

Postby Rick Lipkin » Sat Feb 14, 2015 3:43 pm

Reinaldo

I have been looking for such an algorithm myself .. unfortunately I have had to find the controls manually and resize them manually.

I am not a method kinda person .. It appears your code is for non-mdi windows .. Will your code work with MDI as well ?

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Move controls as window size

Postby reinaldocrespo » Sat Feb 14, 2015 4:13 pm

Hey Rick!

Funny you asked. Just recently I had to adapt it for an MDI app. It would still work the same, though. To keep things easier, I make each MDICHILD window object a property of the class. In this manner I can address it as ::oWndChild.... Tell you what, here's some actual code. I'm not "happy" with this code as I only wrote it as simple as possible to test and prove how controls can be manipulated in placement and size inside a mdichild window and that it'd work.

Code: Select all  Expand view

//---------------------------------------------------//
//
METHOD SetSize( nType, nWidth, nHeight ) CLASS MpCal
local nCntrl := aScan( ::oWnd:aControls, { |e| upper( e:ClassName() ) $ "TTOOLBAR,TREBAR,TBAR,TRIBBONBAR" } )
LOCAL aClient := GetClientRect ( ::oWnd:hWnd ), i

    if nWidth != nil

      if nCntrl > 0 .and. nHeight != Nil ; nHeight -= ::oWnd:aControls[ nCntrl ]:nHeight   ;endif

      IF ::oRibbon:nOption == 1
         ::oPanelExplorer:Move( , , , nHeight )
         ::oPanelCalex:Move( , , nWidth - ::oPanelExplorer:nRight, nHeight )
         
         RETURN NIL

      ENDIF
     
      ::oWndChild:SetSize( aClient[ 4 ]-1, nHeight, .T. )
      ::oWndChild:Move( 0, 0 )

      IF ::oRibbon:nOption == 2
     
         ::oGridViewDlg:SetSize( aClient[4] - 1, nHeight, .T. )
         ::oGridViewDlg:Move( 0, 0 )
         ::oGridViewDlg:Show()
         ::oGridViewDlg:Refresh()

         IF ::oGridView == NIL ;            RETURN NIL   ;         ENDIF

         ::oGridView:SetSize( ::oGridViewDlg:nWidth, ::oGridViewDlg:nHeight , .T. )
         ::oGridView:Move( 0, 0 )
         ::oGridView:SetFocus()

      ENDIF

      IF ::oRibbon:nOption == 3 ... ;ENDIF

    ENDIF

RETURN NIL

 


Hope that helps.

Reinaldo.
Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Move controls as window size

Postby Antonio Linares » Sun Feb 15, 2015 6:17 am

Use FWH layouts! :-)

They work really great
regards, saludos

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

Re: Move controls as window size

Postby joseluisysturiz » Mon Feb 16, 2015 1:26 am

Antonio Linares wrote:Use FWH layouts! :-)

They work really great

Antonio, hay sample o pueden colocar el uso de la clase Layouts.? gracias, saludos...
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Move controls as window size

Postby Daniel Garcia-Gil » Mon Feb 16, 2015 2:15 am

joseluisysturiz wrote:Antonio, hay sample o pueden colocar el uso de la clase Layouts.? gracias, saludos...


http://forums.fivetechsupport.com/viewtopic.php?p=151916#p151916
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Move controls as window size

Postby joseluisysturiz » Mon Feb 16, 2015 4:12 am

Gracias Daniel, revisando, saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Move controls as window size

Postby D.Fernandez » Mon Feb 16, 2015 1:20 pm

Hello, tLayout wotk from resources?

Thank you very much.

Saludos
Ruben Dario Fernandez
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 462
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: Move controls as window size

Postby Daniel Garcia-Gil » Mon Feb 16, 2015 2:43 pm

D.Fernandez wrote:Hello, tLayout wotk from resources?

Thank you very much.

Saludos
Ruben Dario Fernandez


Hello, not work with resources
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Move controls as window size

Postby dbmanfwh » Tue Feb 17, 2015 10:22 am

Any,

I use resources and I tried. Modal windows that go well.
Please see source under someone and develop.

http://www.milkweb.co.kr/DlgResize.zip

Code: Select all  Expand view

// RESOURCE SCRIPT generated by "Pelles C for Windows, version 8.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

// LANGUAGE LANG_KOREAN,SUBLANG_KOREAN

D_BROWSE DIALOGEX FIXED IMPURE 97, 119, 347, 245
STYLE WS_POPUP|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_VISIBLE
EXSTYLE 0x00000100
CAPTION "Dialog Resize"
FONT 9, "MS Sans Serif", 0, 0, 0
{
  CONTROL "", 401, "SysTabControl32", 0x00000000, 200, 56, 140, 84
  CONTROL "undefined static text", -1, "Static", WS_GROUP, 9, 12, 104, 8
  CONTROL "undefined group", -1, "Button", BS_GROUPBOX|WS_DISABLED, 4, 36, 340, 180
  CONTROL "", 101, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 140, 8, 200, 14
  CONTROL "save", 201, "Button", WS_TABSTOP, 208, 220, 64, 20
  CONTROL "cancel", 202, "Button", WS_TABSTOP, 276, 220, 64, 20
  CONTROL "Custom control", 301, "TxBrowse", WS_DISABLED|0x00100000, 12, 56, 180, 84
  CONTROL "Custom control", 302, "TxBrowse", WS_DISABLED|0x00100000, 12, 144, 328, 64
}
 


Code: Select all  Expand view

#include "fivewin.ch"
#include "xbrowse.ch"

/*
  2012.07.08  Charles Kwon made to my suggestion.

  ToDo : 1. Do not act in MDI yet.
         2. When define each control, I wish to can give factor of 4 directions  .or. obj:bFacter(||....)
*/


Static oInfo

FUNCTION Main()

   LOCAL oDlg
   LOCAL oBrw
   LOCAL oBrw2
   LOCAL oFld
   LOCAL oBtn
   LOCAL bSetup := { | oObj, cTitle, nAt, nID, cClsName, oSelf | SetupDlg( oObj, cTitle, nAt, nID, cClsName, oSelf ) }

   SET RESOURCES TO "DlgResiz.dll"

   USE customer NEW   // FiveWin samples

   DEFINE DIALOG oDlg RESOURCE "D_BROWSE"

      oDlg:bStart   := { | | oInfo := TDlgResize():New( oDlg, bSetup ) }
      oDlg:bResized := { | nSizeType, nWidth, nHeight | oInfo:Resize( nWidth, nHeight ) }

      REDEFINE XBROWSE oBrw  ID 301 OF oDlg  AUTOCOLS

      REDEFINE XBROWSE oBrw2 ID 302 OF oDlg  AUTOCOLS

      REDEFINE FOLDER  oFld  ID 401  OF oDlg  PROMPT "&One", "&Two", "&Three"

      REDEFINE BUTTON  oBtn  ID 202  ACTION oDlg:End()

   ACTIVATE DIALOG oDlg

   Set Resources to
   customer->( dbCloseArea() )

RETURN NIL


/*
   Dlg Controls Setup
*/

FUNCTION SetupDlg( oObj, cTitle, nAt, nID, cClsName, oSelf )
   LOCAL oFindObj

   oObj:nTopStyle    := 1        // 1.NONE    2.Upper relative position 3.Follow to Under Control OR Dialog Bottom
   oObj:nLeftStyle   := 1        // 1.NONE    2.Left relative position  3.Follow to Right Control OR Dialog Right
   oObj:nRightStyle  := 1        // 1.NONE    2.Dialog Width           * Appointment Control
   oObj:nBottomStyle := 1        // 1.NONE    2.Dialog Bottom          * Appointment Control

   DO CASE
      CASE nAt == 2                  // undefind static text. Resource Order 2
           oObj:nTopStyle    := 1
           oObj:nLeftStyle   := 1
           oObj:nRightStyle  := 1
           oObj:nBottomStyle := 1

      CASE nAt == 3                  // undefined group   . Resource Order 3
           oObj:nTopStyle    := 1
           oObj:nLeftStyle   := 1
           oObj:nRightStyle  := oSelf:FindByID( 401 )
           oObj:nBottomStyle := oSelf:FindByID( 202 )

      CASE nID == 101               // get                 . Resource Order 4
           oObj:nTopStyle    := 1
           oObj:nLeftStyle   := 3   // Follow to Dialog Right
           oObj:nRightStyle  := 1
           oObj:nBottomStyle := 1

      CASE nId == 201               // save               . Resource Order 5
           oObj:nTopStyle    := 3
           oObj:nLeftStyle   := 3
           oObj:nRightStyle  := 1
           oObj:nBottomStyle := 1

      CASE nID == 202               // cancel            . Resource Order 6
           oObj:nTopStyle    := 3
           oObj:nLeftStyle   := 3
           oObj:nRightStyle  := 1
           oObj:nBottomStyle := 1

      CASE nID == 401             //                    . Resource Order 1
           oObj:nTopStyle    := 1
           oObj:nLeftStyle   := 3
           oObj:nRightStyle  := 1
           oObj:nBottomStyle := 1

      CASE nID == 301              //                    . Resource Order 7
           oObj:nTopStyle    := 1
           oObj:nLeftStyle   := 1
           oObj:nRightStyle  := oSelf:FindByID( 401 )    // Appointment Control
           oObj:nBottomStyle := oSelf:FindByID( 302 )    // or oSelf:aChilds[5]

      CASE nID == 302             //                    . Resource Order 8
           oObj:nTopStyle    := 2
           oObj:nLeftStyle   := 1  // 3
           oObj:nRightStyle  := oSelf:FindByID( 401 )    // or oSelf:aChilds[6]
           oObj:nBottomStyle := oSelf:FindByID( 202 )    // or oSelf:aChilds[6]

   ENDCASE


RETURN NIL


//
//
CLASS TDlgResize

   DATA oDlg
   DATA aChilds AS ARRAY INIT {}

   DATA nTop
   DATA nLeft
   DATA nBottom
   DATA nRight
   DATA nHeight
   DATA nWidth
   DATA bSetup



   METHOD New( oDlg ) CONSTRUCTOR
   METHOD GetChilds()
   METHOD AddChild( hWnd )
   METHOD Resize( nWidth, nHeight )
   METHOD FindByID( nID )

ENDCLASS

METHOD New( oDlg, bSetup ) CLASS TDlgResize
   LOCAL aRect := {}
   LOCAL oChild
   LOCAL nI

   ::oDlg := oDlg

   //aRect := GetCoors( oDlg:hWnd )
   aRect := GetWndRect( oDlg:hWnd )

   ::nTop     :=   aRect[ 1 ]
   ::nLeft    :=   aRect[ 2 ]
   ::nBottom  :=   aRect[ 3 ]
   ::nRight   :=   aRect[ 4 ]

   ::nHeight  :=   aRect[ 3 ] - aRect[ 1 ] + 1
   ::nWidth   :=   aRect[ 4 ] - aRect[ 2 ] + 1

   ::bSetup   :=   bSetup
   ::GetChilds()

    IF ::bSetup <> NIL
       FOR nI := 1 TO LEN( ::aChilds )
           oChild := ::aChilds[ nI ]
           EVAL ( ::bSetup, oChild, GetWindowText( oChild:hWnd ), nI, oChild:nID ,  oChild:cClsName,  Self )
       NEXT
    ENDIF

RETURN Self

//
METHOD GetChilds() CLASS TDlgResize

   ::aChilds := {}
   EnumChildWindows( ::oDlg:hWnd , { | hWnd | ::AddChild( hWnd ) } )

return NIL

//
METHOD AddChild( hWnd ) CLASS TDlgResize
    LOCAL oChild

    oChild := TDlgResizeItem():New( hWnd, Self )

    AADD ( ::aChilds, oChild )

return nil

//
METHOD Resize( nWidth, nHeight ) CLASS TDlgResize
    local ni

    AEVAL ( ::aChilds, {|o|o:lResized := .f. } )
    AEVAL ( ::aChilds, {|o|o:Resize( nWidth, nHeight ) } )
    ::oDlg:Refresh(.f.)

RETURN NIL

//
METHOD FindByID( nID )  CLASS TDlgResize
   LOCAL nI

   FOR nI := 1 TO LEN( ::aChilds )
       IF ::aChilds[nI]:nID == nID
          RETURN ::aChilds[nI]
       ENDIF
   NEXT

   MsgInfo( "ID "+ALLTRIM(STR(nId))+" not found. So return 1")

RETURN 1


#pragma BEGINDUMP
#include <Windows.h>
#include <hbapi.h>
#include <hbapiitm.h>


static PHB_ITEM pCodeBlock = NULL, pParam = NULL;

static BOOL CALLBACK EnumChildProc( HWND hWnd, LPARAM lParam )
{
   PHB_ITEM pNumber = hb_itemPutNL( NULL, ( LONG ) hWnd );

   if( lParam )
      hb_evalBlock( pCodeBlock, pNumber, lParam, NULL );
   else
      hb_evalBlock1( pCodeBlock, pNumber );

   hb_itemRelease( pNumber );

   return TRUE;
}

HB_FUNC( ENUMCHILDWINDOWS )
{
   pCodeBlock = hb_param( 2, HB_IT_BLOCK );
   pParam = hb_param( 3, HB_IT_NUMERIC );
   hb_retl( EnumChildWindows( ( HWND ) hb_parnl( 1 ), EnumChildProc, hb_parnl( 2 ) ) );
   pCodeBlock = NULL;
   pParam = NULL;
}

HB_FUNC( GETDLGCTRLID )
{
   hb_retni( GetDlgCtrlID( ( HWND ) hb_parnl( 1 ) ) );
}

#pragma ENDDUMP


//
CLASS TDlgResizeItem

   DATA oParent
   DATA oDlg
   DATA hWnd

   DATA nTop
   DATA nLeft
   DATA nBottom
   DATA nRight
   DATA nHeight
   DATA nWidth

   DATA nTopStyle
   DATA nLeftStyle
   DATA nRightStyle
   DATA nBottomStyle

   DATA aRect2
   DATA lResized   AS LOGICAL INIT .F.

   DATA nID
   DATA cClsName

   METHOD New() CONSTRUCTOR
   METHOD Resize ( nWidth, nHeight )

ENDCLASS

//
METHOD New( hWnd, oParent ) CLASS TDlgResizeItem
   LOCAL aRect  := {}
   LOCAL aRect2 := {}

   ::oParent := oParent
   ::oDlg    := oParent:oDlg
   ::hWnd    := hWnd

   aRect     := GetCoors( ::hWnd )       // Absolute coordinate
   ::aRect2  := GetWndRect( ::hWnd )

   ::nId      := GetDlgCtrlID( ::hWnd )
   ::cClsName := GetClassName( ::hWnd )


   ::nTop     :=   aRect[ 1 ]
   ::nLeft    :=   aRect[ 2 ]
   ::nBottom  :=   aRect[ 3 ]
   ::nRight   :=   aRect[ 4 ]

   ::nHeight  :=   aRect[ 3 ] - aRect[ 1 ] + 1
   ::nWidth   :=   aRect[ 4 ] - aRect[ 2 ] + 1

RETURN Self

//
METHOD Resize ( nWidth, nHeight ) CLASS TDlgResizeItem
   LOCAL nTop
   LOCAL nLeft
   LOCAL nHeight2
   LOCAL nWidth2
   LOCAL oObj
   LOCAL aRect
   LOCAL lNoChangeHeight := .f.
   LOCAL lNoChangeWidth  := .f.

   IF ::lResized
      RETURN NIL
   ENDIF

   ::lResized := .T.

   IF nHeight >= ::oParent:nHeight
      nTop     := int ( ( nHeight  *  ::nTop     / ::oParent:nHeight )  )       // top
      nHeight2 := int ( ( nHeight  *  ::nHeight  / ::oParent:nHeight )  )       // height
   ELSE
      nTop     := ::nTop
      nHeight2 := ::nHeight
      lNoChangeHeight := .t.
   ENDIF

   IF nWidth >= ::oParent:nWidth
      nLeft   := int ( ( nWidth  *   ::nLeft  / ::oParent:nWidth  )  )
      nWidth2 := int ( ( nWidth  *   ::nWidth / ::oParent:nWidth  )  )
   ELSE
      nLeft  := ::nLeft
      nWidth2 := ::nWidth
      lNoChangeWidth  := .t.
   ENDIF

   /*

   IF lNoChangeHeight .or. lNoChangeWidth
      MoveWindow( ::hWnd, ::nTop, ::nLeft, ::nWidth, ::nHeight, .t. )
      RETURN NIL
   ENDIF
   */



   DO CASE
      CASE ::nTopStyle == 1
           nTop := ::nTop
      CASE ::nTopStyle == 3
           nTop := nHeight - ::nHeight - ( ::oParent:nBottom - ::aRect2[3] ) + 1
   ENDCASE


   DO CASE
      CASE ::nLeftStyle == 1
           nLeft := ::nLeft

      CASE ::nLeftStyle == 3
            nLeft := nWidth - ::nWidth - ( ::oParent:nRight - ::aRect2[4] ) + 1

   ENDCASE

   IF VALTYPE ( ::nRightStyle ) == "N"
      DO CASE
         CASE ::nRightStyle == 1
              nWidth2 := ::nWidth
      ENDCASE
   ELSE
      oObj := ::nRightStyle
      oObj:Resize( nWidth, nHeight )
      aRect := GetCoors( oObj:hWnd )
      nWidth2 := aRect[2] - nLeft - ( oObj:aRect2[2] - ::aRect2[4] )
   ENDIF

   IF VALTYPE( ::nBottomStyle ) == "N"
      DO CASE
         CASE ::nBottomStyle == 1
              nHeight2 := ::nHeight
      ENDCASE
   ELSE
      oObj := ::nBottomStyle
      oObj:Resize( nWidth, nHeight )
      aRect := GetCoors( oObj:hWnd )
      nHeight2 := aRect[1]  - nTop - ( oObj:aRect2[1] - ::aRect2[3] )
   ENDIF

   MoveWindow( ::hWnd, nTop, nLeft, nWidth2, nHeight2, .t. )

RETURN NIL

 
Regards,
Moon
FWH 16.11 | xHarbour | Harbour | BCC72 | DBF | ADS | MySQL | DrLib
dbmanfwh
 
Posts: 38
Joined: Tue Mar 04, 2008 3:44 pm
Location: Korea

Re: Move controls as window size

Postby joseluisysturiz » Thu May 14, 2015 7:16 pm

Daniel Garcia-Gil wrote:
D.Fernandez wrote:Hello, tLayout wotk from resources?

Thank you very much.

Saludos
Ruben Dario Fernandez


Hello, not work with resources


Saludos, aun la TLayout sigue sin trabajar desde recursos.? gracias, saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Move controls as window size

Postby Silvio.Falconi » Fri May 15, 2015 6:47 am

Please a question

the dialogresize class run also with x,y sources or only with resources ?
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 52 guests