Page 1 of 1

Error in Tbar

Posted: Thu Nov 04, 2021 2:01 pm
by Maurizio
Hello
if I delete a button in TBAR, the button is deleted but when the button following the deleted one has the focus I see the BMP of the deleted button.


https://drive.google.com/file/d/1J0lQ9ln18UKuYMI1XLI26SCoyvcq5XRt/view?usp=sharing



Code: Select all | Expand

#include "FiveWin.ch"
//----------------------------------------------------------------------------//

function Main()

   local oIco, oBar, oBmp ,oWnd

   
   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
      TITLE "FiveWin sample" ;
      COLOR "B/W"
     

   DEFINE BUTTONBAR oBar _3D SIZE 60, 60 OF oWnd

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\new.bmp" FLAT ;
      ACTION MsgInfo( "New" ) ;
      TOOLTIP "Creates a new document"

 
   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\floppy.bmp" FLAT ;
      ACTION MsgInfo( Time() ) TOOLTIP "Saves this document"

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT ;
      ACTION oWnd:End() TOOLTIP "Exit this app" GROUP

 
  oBar:Del(2)
 

   
   ACTIVATE WINDOW oWnd

return nil

 

Maurizio

Re: Error in Tbar

Posted: Thu Nov 04, 2021 2:16 pm
by nageswaragunupudi
We are looking into this.

Re: Error in Tbar

Posted: Thu Nov 04, 2021 3:08 pm
by karinha

Code: Select all | Expand


// \samples\MAURIZIO.PRG

#Include "FiveWin.ch"

STATIC oBar, oBtn1, oBtn2, oBtn3

STATIC lNotLook := .T.

FUNCTION Main()

   LOCAL oIco, oBmp, oWnd
   
   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
      TITLE "FiveWin: Delete a Button" ;
      COLOR "B/W"

   DEFINE BUTTONBAR oBar _3D SIZE 60, 60 OF oWnd

   DEFINE BUTTON oBtn1 OF oBar FILENAME "..\bitmaps\16x16\new.bmp" FLAT    ;
      ACTION( mDeleteBut() )                                               ;
      TOOLTIP "Delete a Button"
 
   DEFINE BUTTON oBtn2 OF oBar FILENAME "..\bitmaps\16x16\floppy.bmp" FLAT ;
      ACTION MsgInfo( Time() ) TOOLTIP "Saves this document"

   DEFINE BUTTON oBtn3 OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT   ;
      ACTION oWnd:End() TOOLTIP "Exit this app" GROUP

    ACTIVATE WINDOW oWnd

RETURN NIL

FUNCTION mDeleteBut() // Delete Button for Maurizio.

   IF lNotLook // := .T.

      oBar:Del( 2 )

      oBtn2:Hide()

      oBar:BtnAdjust()
      oBar:Refresh()

      lNotLook := .F.

   ELSE

      ? "WOW!! Invisible Button - Number 2"

   ENDIF

RETURN NIL

// fin / end
 


Regards, saludos.

Re: Error in Tbar

Posted: Fri Nov 05, 2021 8:03 am
by Maurizio
Grazie Karinha

Your workaround works
Let's see if Rao solves the problem in the tBar class .

Maurizio

Re: Error in Tbar

Posted: Fri Nov 05, 2021 7:08 pm
by nageswaragunupudi
Will you both try this fix and give your valuable feedback?

Present code in bar.prg

Code: Select all | Expand

METHOD Del( nPos ) CLASS TBar

   local n
   local lGroup:= ::aControls[ nPos ]:lGroup

   ADel( ::aControls, nPos )
 


Modify as:

Code: Select all | Expand

METHOD Del( nPos ) CLASS TBar

   local n
   local lGroup:= ::aControls[ nPos ]:lGroup

   ::aControls[ nPos ]:Hide()  // insert these
   ::aControls[ nPos ]:End()   // two lines
   ADel( ::aControls, nPos )
 

Re: Error in Tbar

Posted: Mon Nov 08, 2021 7:50 am
by Maurizio
Thanks Rao
with your modifications it works :D

Maurizio
www.nipeservice.com