Page 1 of 1

activate an online button

Posted: Wed Feb 12, 2025 11:16 pm
by Silvio.Falconi
In a dialog I have a buttonbar

Code: Select all | Expand

 DEFINE BUTTONBAR oBar OF oDlg  SIZE 100,70  TOP NOBORDER  2015
then on activate I cal the functions

Code: Select all | Expand

Btnbar(1,oDlg:oBar,oDlg,oDbf,oBrw,aBtnBrow[4]),;
to activate the buttonbar oBar (different menu barchange.prg thanks to Cristobal )

but the button number 6 is hided at init

and then the function Hide_Radio2(oRadio2,.f.,oSay,oLines,oBar) to show or not the button number 6

but when I try to make oBar:aControls[6]:show()

Code: Select all | Expand

 
 Error description: Error BASE/1004  Metodo non disponibile: ACONTROLS
   Args:
     [   1] = U   

Stack Calls
===========
   Called from: source\PConti.prg => ACONTROLS( 0 )
   Called from: source\PConti.prg => HIDE_RADIO2( 681 )
   
   
It tells me it can't find the aControls method.....why ?


please try this small test

Code: Select all | Expand

// developed by Cristobal Navarro

#include 'fivewin.ch'
#include 'xbrowse.ch'
#include "constant.ch"

Function test()

   local oDlg,oDbf,oFont
   local oBar

   local  nBottom   := 27.2
   local  nRight    := 89
   local  nWd       := Max( nRight * DLG_CHARPIX_W, 180 )
   local  nHt       := nBottom * DLG_CHARPIX_H

   DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
         TiTle "test"
      oDlg:lHelpIcon := .F.      

   @ 90,  10 Button "Second bar" size 100,18 PIXEL OF oDlg action Btnbar(2,oDlg:oBar,oDlg)
   @ 90, 200 Button "First bar"  size 100,18 PIXEL OF oDlg action Btnbar(1,oDlg:oBar,oDlg)

   @ 90, 400 Button "hide/show button"  size 100,18 PIXEL OF oDlg action Hide_button(oDlg:oBar)

   ACTIVATE DIALOG oDlg  CENTER   ;
          ON INIT ( Btnbar(0,oBar,oDlg), Btnbar(1,oDlg:oBar,oDlg ))
RETURN NIL

//----------------------------------------------------------------------------//

Function Btnbar(nBar,oBar,oDlg)  // ,aBtnBar

   local aBtnBar
   local x

   if Valtype( oBar ) = "O"
      For x := Len( oBar:aControls ) to 1 step - 1
         oBar:Del( x )
      Next x
   endif

  Do case
  case nbar = 0
     DEFINE BUTTONBAR oBar OF oDlg  SIZE 80,70  TOP NOBORDER  2015

  case nbar = 1
   aBtnBar := array(6)
   DEFINE BUTTON aBtnBar[1] OF oBar PROMPT "New"       action msginfo()
   DEFINE BUTTON aBtnBar[2] OF oBar PROMPT "Modify"    action msginfo()
   DEFINE BUTTON aBtnBar[3] OF oBar PROMPT "Duplicate" action msginfo()
   DEFINE BUTTON aBtnBar[4] OF oBar PROMPT "Del"       action msginfo()
   DEFINE BUTTON aBtnBar[5] OF oBar PROMPT "Print"     action msginfo()
   DEFINE BUTTON aBtnBar[6] OF oBar PROMPT "Help"      action msginfo("Help")
   
              aBtnBar[6]:hide()
              
  case nbar = 2
   aBtnBar := array(2)
   DEFINE BUTTON aBtnBar[1] OF oBar PROMPT "Del"       action msginfo("Del")
   DEFINE BUTTON aBtnBar[2] OF oBar PROMPT "Print"     action msginfo("Print")

  endcase

return oBar

//----------------------------------------------------------------------------//


Function Hide_button(oBar)
        oBar:arcontrols[6]:show()
   return nil


Re: activate an online button

Posted: Thu Feb 13, 2025 5:37 am
by Antonio Linares
Dear Silvio,

ON INIT ( Btnbar(0,@oBar,oDlg), Btnbar(1,oDlg:oBar,oDlg ))

Re: activate an online button

Posted: Thu Feb 13, 2025 6:28 am
by Silvio.Falconi
Fir now i resolved making another buttonbar case 3