FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour add items on ScrollPanels
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
add items on ScrollPanels
Posted: Thu Jun 08, 2023 09:54 AM
I need to add items to a scrollpanel
initially the dialog inserts only one item, but if the user press the 2 or 3 button he can insert 2 or 3 items



the test I made add the items

the second oitem is too big from first why ?

the oitem right must be opanel:nright-50
why is more big ?



the test
Code (fw): Select all Collapse
 
 
#include"fivewin.ch"

Function  Test()
    local oDlg
    local nRow
    local aBtnCalc:=array(9)
    local oInvoice
    local aItems := {}
    local nItems:= 1
    local nRowItems:= 10

       oFont := TFont():New( "Tahoma", 0, 14,, )
       oBold := TFont():New( "Tahoma", 0, 14,,.t. )


DEFINE DIALOG oDlg SIZE 878, 680 PIXEL;   
 FONT oFont    Title "test"  ;
 STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
              WS_MAXIMIZEBOX, WS_MINIMIZEBOX, WS_THICKFRAME )


nRow:=30
  @  nRow,2 BUTTON aBtnCalc[1] PROMPT "2" SIZE 20,30 PIXEL of oDlg ;
            ACTION  AddItems(oInvoice,@aItems,2,@nRowItems)
 nRow+=32
 @  nRow,2 BUTTON aBtnCalc[2] PROMPT "3" SIZE 20,30 PIXEL of oDlg ;
            ACTION  AddItems(oInvoice,@aItems,3,@nRowItems)



 oDlg:bResized  := <||
                   oRect                        := oDlg:GetCliRect()
 >

  ACTIVATE DIALOG oDlg CENTERED  ;
                       ON INIT ( oInvoice := CreatePanel( 060,330,180,550,oDlg),;
                                 AddItems(oInvoice,@aItems,nItems,@nRowItems),;
                                 oInvoice:CheckResize(),;
                       oDlg:resize()   )
Return nil
//------------------------------------------------------------------------------------------------//
Function CreatePanel(ntop,nLeft,nRight,nBottom,oDlg)
   local oPanel
   oPanel   := TScrollPanel():New( ntop,nLeft,nRight,nBottom,oDlg, .t. )
   oPanel:nRightMargin     := 10
   oPanel:nBottomMargin    := 80
   oPanel:WinStyle(WS_BORDER, .t.)
   Return oPanel
//------------------------------------------------------------------------------------------------//
Function AddItems(oPanel,aItems,nItems,nRowItems)
    local nCol:= 10
    local nHeight:= 130
    local aGrad:= { CLR_GREEN,CLR_GREEN}
    local n
    local oItem
    local nWidth:= oPanel:nRight-50

    DEFINE BRUSH oBrush GRADIENT aGrad

    For n= 1 to  nItems

      oItem:=Tpanel():New( nRowItems, nCol, nHeight+nRowItems,nWidth , oPanel, , , .t. )
      oItem:SetBrush( oBrush )

      aadd( aItems, {oItem,nRowItems,oItem:cVarname,nWidth} )

      nRowItems+=nHeight+2
   next

    xbrowser  aItems
   oPanel:setRange()
   Return oPanel

I check with xbrowser



the width of first is 500, why from second is 820 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: add items on ScrollPanels
Posted: Thu Jun 08, 2023 06:45 PM
Silvio,

Change
Code (fw): Select all Collapse
local nWidth := oPanel:nRight-50
with
Code (fw): Select all Collapse
local nWidth := iif(Len(oPanel:aControls)==0, oPanel:nRight-50, oPanel:aControls[1]:nRight)
Regards,

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: add items on ScrollPanels
Posted: Fri Jun 09, 2023 08:14 AM

thanks

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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

Continue the discussion