To Nageswrao Del Objs on TscrollPanel

To Nageswrao Del Objs on TscrollPanel

Postby Silvio.Falconi » Mon Feb 26, 2024 12:57 pm

Image


Nages,

I create a Scroll Panel with some Objs and save the obj on adata array

To manage open a Xbrowse with aData

I wish erase the obj on TscrollPanel When Click (SetCheck) on one items on xbrowse except product number 1

and del item on adata and refresh the oBrw

how I can resolve ?

I Tried with ( but run bad)

FOR i := 1 TO LEN(oBrw:aCols)
oCol := oBrw:aCols[ i ]
oCol:bLDClickData := { || Erase_Items(oBrw,oPanel) }
NEXT

Function Erase_Items(oBrw,oPanel)
local nItem:= oBrw:aArrayData[ oBrw:nArrayAt ][2]
aDel(oBrw:aArraydata,nItem-1)
// xbrowser oBrw:aArraydata
oPanel:aControls[nItem]:destroy()
oBrw:refresh()
oPanel:refresh()
return nil



Code: Select all  Expand view
Function Manage_Items(aData,oBrowse)
    local oDlg
   local oBar
   local oFont
   local oBold
   local nWd  := GetSysMetrics(0) * .30
   local nHt  := (GetSysMetrics(1) / 3.5 ) -20
   local oBtn := array(3)
   local aBmp:= {" ","elimina.bmp"}
   local aCols    := {}


     For n= 1 to Len(aData)
        If  !aData[n][5]
           else
          AAdd( aCols, {aData[n][1],n,!aData[n][5]})
       Endif
     Next

   DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL ;   //TRUEPIXEL
       TITLE  "Products" ;
       FONT oFont   COLOR CLR_BLACK, RGB( 245,245,235)  ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)


    @ 10,10 XBROWSE oBrw SIZE -10,-20 PIXEL OF oDlg ;
          DATASOURCE aCols ;
          COLUMNS 1,3 ;
          HEADERS "Descrizione","R" ;
          COLSIZES 300, 40 ;
           NOBORDER  FONT oFONT

        WITH OBJECT oBrw
            :lHScroll:=.f.
            :lRecordSelector:= .F.
            :lDrawBorder := .t.

          WITH OBJECT :aCols[ 2]
             :SetCheck(aBmp, .t. )
             :nHeadBmpNo    := 2
          END
          :CreateFromCode()
       END

      ACTIVATE DIALOG oDlg CENTERED
    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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nageswrao Del Objs on TscrollPanel

Postby nageswaragunupudi » Tue Feb 27, 2024 12:28 pm

To delete nth control of a Panel/dialog/window
Code: Select all  Expand view
oPanel:aControls[ n ]:End()
HB_ADel( oPanel:aControls[ n ], n, .t. )


To delete current row in XBrowse ( applies to arrays, dbf, ado or any data source)
Code: Select all  Expand view
oBrw:Delete()
oBrw:Refresh()


This code:
Code: Select all  Expand view
FOR i := 1 TO LEN(oBrw:aCols)
oCol := oBrw:aCols[ i ]
oCol:bLDClickData := { || Erase_Items(oBrw,oPanel) }
NEXT


can be written as:
Code: Select all  Expand view
oBrw:bLDClickDatas :=  { || Erase_Items(oBrw,oPanel) }
Regards

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

Re: To Nageswrao Del Objs on TscrollPanel

Postby Silvio.Falconi » Wed Feb 28, 2024 8:09 am

nageswaragunupudi wrote:To delete nth control of a Panel/dialog/window
Code: Select all  Expand view
oPanel:aControls[ n ]:End()
HB_ADel( oPanel:aControls[ n ], n, .t. )


To delete current row in XBrowse ( applies to arrays, dbf, ado or any data source)
Code: Select all  Expand view
oBrw:Delete()
oBrw:Refresh()


This code:
Code: Select all  Expand view
FOR i := 1 TO LEN(oBrw:aCols)
oCol := oBrw:aCols[ i ]
oCol:bLDClickData := { || Erase_Items(oBrw,oPanel) }
NEXT


can be written as:
Code: Select all  Expand view
oBrw:bLDClickDatas :=  { || Erase_Items(oBrw,oPanel) }





Mr Rao

this del the record on Browse but on Panel there are also the btnbmp (oBj)
Code: Select all  Expand view

Function Erase_Items(oBrw,oPanel)
   local  nItem:=  oBrw:aArrayData[ oBrw:nArrayAt ][2]

   oBrw:Delete()
   oBrw:Refresh()

        oPanel:aControls[ nItem ]:End()
        HB_ADel( oPanel:aControls[ nItem ], nItem, .t. )

        oPanel:refresh()

   return nil


Image

the btnbmps there are also on Panel scroll as you can see on Video

I tried with

oPanel:CheckResize() and oPanel:Setrange()

I see allway the box

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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nageswrao Del Objs on TscrollPanel

Postby Silvio.Falconi » Thu Feb 29, 2024 8:50 am

Nages

oPanel:aControls[ nItem ]:End()
HB_ADel( oPanel:aControls[ nItem ], nItem, .t. )
ASize( oPanel:aControls, Len( oPanel:aControls ) )
oPanel:SetRange()
oPanel:refresh()


I saw on oPanel:aControls there are also the records

Image

also if I make ASize( oPanel:aControls, Len( oPanel:aControls ) -1 ) then not refresh the panel


if there are any deleted objects the btnbmp should reposition themselves

Image

if I delete products 3 and 4, product number 5 must be positioned after product 2

How I can resolve it ?
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nageswrao Del Objs on TscrollPanel

Postby nageswaragunupudi » Mon Mar 04, 2024 7:12 am

Code: Select all  Expand view
function DeleteControl( oPanel, nItem )

   local nTop, nLeft
   
   for n := Len( oPanel:aControls ) to nItem + 1 STEP -1
      oPanel:aControls[ n ]:nTop := oPanel:aControls[ n - 1 ]:nTop
      oPanel:aControls[ n ]:nLeft:= oPanel:aControls[ n - 1 ]:nLeft
   next
   oPanel:aControls[ nItem ]:End()
   HB_ADel( oPanel:aControls, nItem, .t. )
   oPanel:Refresh()
     
return nil
Regards

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

Re: To Nageswrao Del Objs on TscrollPanel

Postby Silvio.Falconi » Mon Mar 04, 2024 8:33 am

nageswaragunupudi wrote:
Code: Select all  Expand view
function DeleteControl( oPanel, nItem )

   local nTop, nLeft
   
   for n := Len( oPanel:aControls ) to nItem + 1 STEP -1
      oPanel:aControls[ n ]:nTop := oPanel:aControls[ n - 1 ]:nTop
      oPanel:aControls[ n ]:nLeft:= oPanel:aControls[ n - 1 ]:nLeft
   next
   oPanel:aControls[ nItem ]:End()
   HB_ADel( oPanel:aControls, nItem, .t. )
   oPanel:Refresh()
     
return nil


Sorry Nages,
but not erase the btnbmp on Panelscroll

I made

//I want erase only from second column of oBrw
oCol := oBrw:aCols[ 2 ]
oCol:bLDClickData := { || Erase_Items(oBrw,oPanel) }



Function Erase_Items(oBrw,oPanel,aData,oDlg,oFontSmall)
local nItem:= oBrw:aArrayData[ oBrw:nArrayAt ][2]

oBrw:Delete()
oBrw:Refresh()

DeleteControl( oPanel, nItem )

return nil

function DeleteControl( oPanel, nItem )

local nTop, nLeft

for n := Len( oPanel:aControls ) to nItem + 1 STEP -1
oPanel:aControls[ n ]:nTop := oPanel:aControls[ n - 1 ]:nTop
oPanel:aControls[ n ]:nLeft:= oPanel:aControls[ n - 1 ]:nLeft
next
oPanel:aControls[ nItem ]:End()
HB_ADel( oPanel:aControls, nItem, .t. )
oPanel:Refresh()

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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nageswrao Del Objs on TscrollPanel

Postby Silvio.Falconi » Mon Mar 04, 2024 10:06 am

Not run ok

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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nageswrao Del Objs on TscrollPanel

Postby nageswaragunupudi » Mon Mar 04, 2024 12:57 pm

Let me check
Regards

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

Re: To Nageswrao Del Objs on TscrollPanel

Postby nageswaragunupudi » Mon Mar 04, 2024 1:19 pm

This is working perfectly for me
Code: Select all  Expand view
#include "fivewin.ch"

static cFolder := "c:\fwh\bitmaps\pngs\"

function Main()

   local oDlg, oFont, oPanel, oBrw
   local aImages

   aImages  := DIRECTORY( cFolder + "
*.png" )

   DEFINE FONT oFont NAME "
TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 800,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,450 XBROWSE oBrw SIZE 280,-20 PIXEL OF oDlg ;
      DATASOURCE aImages COLUMNS 1,{ || "
" } ;
      HEADERS "
IMAGE", " " ;
      CELL LINES NOBORDER FOOTERS

   WITH OBJECT oBrw
      :nStretchCol   := 1
      :RecSelShowRecNo()
      WITH OBJECT :aCols[ 2 ]
         :AddBitmap( "
c:\fwh\bitmaps\32x32\no.bmp" )
         :bBmpData := { || 1 }
         :bLDClickData  := { || DelImage( oBrw, oPanel ) }
      END
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oPanel := BuildPanel( oDlg, aImages ) )

   RELEASE FONT oFont

return nil

static function BuildPanel( oDlg, aImages )

   local oPanel, img
   local nRow  := 20
   local nCol  := 20

   oPanel := TScrollPanel():New( 20, 20, 400, 440, oDlg )

   for each img in aImages
      CreateBtn( oPanel, img, @nRow, @nCol )
   next

   oPanel:SetRange()

return oPanel

static function CreateBtn( oPanel, aImg, nRow, nCol )

   @ nRow, nCol BTNBMP PROMPT cFileNoExt( aImg[ 1 ] ) ;
      FILE cFolder + aImg[ 1 ] ;
      SIZE 72,96 PIXEL OF oPanel 2007

   if nCol > 200
      nRow  += 100
      nCol  :=  20
   else
      nCol  += 90
   endif

return nil

static function DelImage( oBrw, oPanel )

   local nItem    := oBrw:nArrayAt

   if DeleteControl( oPanel, nItem )
      oBrw:Delete()
      oBrw:Refresh()
   endif

return nil

static function DeleteControl( oPanel, nItem )

   local nTop, nLeft, nLen, n

   if ( nLen := Len( oPanel:aControls ) ) == 1 .or. nItem == nLen
      return .f.
   endif

   for n := nLen to nItem + 1 STEP -1
      oPanel:aControls[ n ]:nTop := oPanel:aControls[ n - 1 ]:nTop
      oPanel:aControls[ n ]:nLeft:= oPanel:aControls[ n - 1 ]:nLeft
   next
   oPanel:aControls[ nItem ]:End()
   HB_ADel( oPanel:aControls, nItem, .t. )
   oPanel:Refresh()

return .t.


Image
Regards

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

Re: To Nageswrao Del Objs on TscrollPanel

Postby Silvio.Falconi » Mon Mar 04, 2024 9:13 pm

nageswaragunupudi wrote:This is working perfectly for me
Code: Select all  Expand view
#include "fivewin.ch"

static cFolder := "c:\fwh\bitmaps\pngs\"

function Main()

   local oDlg, oFont, oPanel, oBrw
   local aImages

   aImages  := DIRECTORY( cFolder + "
*.png" )

   DEFINE FONT oFont NAME "
TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 800,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,450 XBROWSE oBrw SIZE 280,-20 PIXEL OF oDlg ;
      DATASOURCE aImages COLUMNS 1,{ || "
" } ;
      HEADERS "
IMAGE", " " ;
      CELL LINES NOBORDER FOOTERS

   WITH OBJECT oBrw
      :nStretchCol   := 1
      :RecSelShowRecNo()
      WITH OBJECT :aCols[ 2 ]
         :AddBitmap( "
c:\fwh\bitmaps\32x32\no.bmp" )
         :bBmpData := { || 1 }
         :bLDClickData  := { || DelImage( oBrw, oPanel ) }
      END
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oPanel := BuildPanel( oDlg, aImages ) )

   RELEASE FONT oFont

return nil

static function BuildPanel( oDlg, aImages )

   local oPanel, img
   local nRow  := 20
   local nCol  := 20

   oPanel := TScrollPanel():New( 20, 20, 400, 440, oDlg )

   for each img in aImages
      CreateBtn( oPanel, img, @nRow, @nCol )
   next

   oPanel:SetRange()

return oPanel

static function CreateBtn( oPanel, aImg, nRow, nCol )

   @ nRow, nCol BTNBMP PROMPT cFileNoExt( aImg[ 1 ] ) ;
      FILE cFolder + aImg[ 1 ] ;
      SIZE 72,96 PIXEL OF oPanel 2007

   if nCol > 200
      nRow  += 100
      nCol  :=  20
   else
      nCol  += 90
   endif

return nil

static function DelImage( oBrw, oPanel )

   local nItem    := oBrw:nArrayAt

   if DeleteControl( oPanel, nItem )
      oBrw:Delete()
      oBrw:Refresh()
   endif

return nil

static function DeleteControl( oPanel, nItem )

   local nTop, nLeft, nLen, n

   if ( nLen := Len( oPanel:aControls ) ) == 1 .or. nItem == nLen
      return .f.
   endif

   for n := nLen to nItem + 1 STEP -1
      oPanel:aControls[ n ]:nTop := oPanel:aControls[ n - 1 ]:nTop
      oPanel:aControls[ n ]:nLeft:= oPanel:aControls[ n - 1 ]:nLeft
   next
   oPanel:aControls[ nItem ]:End()
   HB_ADel( oPanel:aControls, nItem, .t. )
   oPanel:Refresh()

return .t.


Image





Of Course your test run ok But

I tried to erase all buttons except one , then I press the scrollbar of panel scroll and I had this

Image

when I had only two buttons I cannot delete printer button

Image


then I have another situation
the final user can insert items directly on tpanel, only on another dialog can delete the btnbmp
these items are quick links to recall some application procedures, so each btnbmp is associated with an action to a Function.
the final user can insert items from a Menu popup as this

Code: Select all  Expand view

MENU oMenu POPUP
     MENUITEM "Procedure1"   ;
       ACTION   CreateBtn( oPanel, "C:\work\fwh\bitmaps\pngs\image1.PNG", @nRow, @nCol,"Procedure1",{||Dummy1()} )
     MENUITEM "Procedure2"   ;
       ACTION   CreateBtn( oPanel, "C:\work\fwh\bitmaps\pngs\image2.PNG", @nRow, @nCol,"Procedure2",{||Dummy1()} )
     ENDMENU
   ACTIVATE POPUP oMenu WINDOW oPanel AT 0, 0
 
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nageswrao Del Objs on TscrollPanel

Postby nageswaragunupudi » Tue Mar 05, 2024 2:37 am

when I had only two buttons I cannot delete printer button

Yes. The function I provided does not allow the last control to be deleted.
Regards

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

Re: To Nageswrao Del Objs on TscrollPanel

Postby Silvio.Falconi » Tue Mar 05, 2024 8:36 am

nageswaragunupudi wrote:
when I had only two buttons I cannot delete printer button

Yes. The function I provided does not allow the last control to be deleted.


Yes. I understood.

Do have you tried deleting all the btnbmps and moving the scrollbar?

It makes this mistake for me

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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nageswrao Del Objs on TscrollPanel

Postby nageswaragunupudi » Tue Mar 05, 2024 11:44 am

I see the problem. Thanks.
Let me fix it
Regards

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

Re: To Nageswrao Del Objs on TscrollPanel

Postby Silvio.Falconi » Tue Mar 05, 2024 12:10 pm

nageswaragunupudi wrote:I see the problem. Thanks.
Let me fix it



Nages,
I need to save the buttons in the archive (links.dbf) because the application must display the buttons at other times when the application is used by users
I sent a test
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nageswrao Del Objs on TscrollPanel

Postby nageswaragunupudi » Tue Mar 05, 2024 12:33 pm

nageswaragunupudi wrote:I see the problem. Thanks.
Let me fix it

Please try this function instead
Code: Select all  Expand view
static function DeleteControl( oPanel, nItem )

   local nTop, nLeft, nLen, n

   if ( nLen := Len( oPanel:aControls ) ) == 1 .or. nItem == nLen
      return .f.
   endif

   for n := nLen to nItem + 1 STEP -1
      oPanel:aControls[ n ]:nTop := oPanel:aControls[ n - 1 ]:nTop
      oPanel:aControls[ n ]:nLeft:= oPanel:aControls[ n - 1 ]:nLeft
   next
   oPanel:aControls[ nItem ]:End()
   HB_ADel( oPanel:aControls, nItem, .t. )

   WITH OBJECT oPanel
      n  := :nPos
      :GoTop()
      :SetRange()
      :GoToPos( MIN( n, oPanel:nScrollRange ) )
      :Refresh()
   END

return .t.
 


We'll look into other issues later
Regards

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 68 guests