add items on ScrollPanels

add items on ScrollPanels

Postby Silvio.Falconi » Thu Jun 08, 2023 9: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

Image

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: Select all  Expand view

 
#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

Image

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

Re: add items on ScrollPanels

Postby Cgallegoa » Thu Jun 08, 2023 6:45 pm

Silvio,

Change
Code: Select all  Expand view
local nWidth := oPanel:nRight-50

with
Code: Select all  Expand view
local nWidth := iif(Len(oPanel:aControls)==0, oPanel:nRight-50, oPanel:aControls[1]:nRight)

Regards,
Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 491
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: add items on ScrollPanels

Postby Silvio.Falconi » Fri Jun 09, 2023 8:14 am

thanks
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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 57 guests