btnbmp activated when selecting a record

Post Reply
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

btnbmp activated when selecting a record

Post by Silvio.Falconi »

similarly to Cristobal's example barchange.prg that uses a buttonbar and some buttons, I would like to do the same thing but without the buttonbar i.e. I have 6 buttons under an xbrowse (the ones that start from the left)

Image

and when I click on a record I would like to display only some of them, how could I do it?

perhaps I must use Newat of bar class But I not Know How make

I tried with

Code: Select all | Expand

@  oBrw:nBottom+5, 5 BUTTONBAR oBar SIZE 90,200 BUTTONSIZE 90,24  OF oDlg
and it make this error

Code: Select all | Expand

Error occurred at: 03/08/25, 12:22:05
   Error description: Error FiveWin/6  Cannot create window or control: 
Class: TBAR
Caption: 
System Error: Impossibile creare una finestra secondaria di primo livello.


Stack Calls
===========
   Called from: .\source\classes\window.prg => WNDCREATEERROR( 898 )
   Called from: .\source\classes\window.prg => TBAR:CREATE( 881 )
   Called from: .\source\classes\bar.prg => TBAR:NEWAT( 500 )
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
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

Re: btnbmp activated when selecting a record

Post by Silvio.Falconi »

Now I change the position of Buttonbar and seem run but there is another error when i I try to create buttons


pls try the test

Code: Select all | Expand

function Main()

   local oDlg, oBrw, oFont
   local oDbf
   local oBar

 DEFINE DIALOG oDlg SIZE 640,300 PIXEL TRUEPIXEL;   //FONT oFont
        TITLE cTitle COLOR CLR_BLACK, DLG_nColorDlg  ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)

 @ 40, 10 XBROWSE oBrw OF oDlg SIZE oDlg:nWidth-20,200 PIXEL ;  // -10,-40
      AUTOCOLS DATASOURCE oDbf NOBORDER

WITH OBJECT oBrw
   :CreateFromCode()
         END
 ACTIVATE DIALOG oDlg CENTERED  ;
         ON INIT ( Btnbar(0,oBar,oDlg,oDbf,oBrw),;
              Btnbar(1,oDlg:oBar,oDlg,oDbf,oBrw) )

   RELEASE FONT oFont

   return nil


Static Function Btnbar(nBar,oBar,oDlg,oDbf,oBrw)
   local n
   local aBtnMenu
   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
           @  oBrw:nBottom+6, 10 BUTTONBAR oBar SIZE 450,22 BUTTONSIZE 90,24  OF oDlg

            oBar:bClrGrad := { | lPressed | If( ! lPressed,;
                 { { 1, DLG_nColorBar1, DLG_nColorBar1} },;
                 { { 1, DLG_nColorBar2, DLG_nColorBar2} } ) }


      case nbar = 1
         aBtnMenu := array(6)
          DEFINE BUTTON aBtnMenu[1] OF oBar PROMPT "Nuovo" RESOURCE "NEW_SMALLBRW"  LEFT;
                 ACTION  NIL
          DEFINE BUTTON aBtnMenu[2] OF oBar PROMPT "Modifica" RESOURCE "MOD_SMALLBRW"  LEFT;
                 ACTION  NIL
         DEFINE BUTTON aBtnMenu[3] OF oBar PROMPT "Elimina" RESOURCE "CAN_SMALLBRW"  LEFT;
                 ACTION  NIL
         DEFINE BUTTON aBtnMenu[4] OF oBar PROMPT "Duplica" RESOURCE "DPL_SMALLBRW"  LEFT;
                 ACTION  NIL
         DEFINE BUTTON aBtnMenu[5] OF oBar PROMPT "Elimina" RESOURCE "CAN_SMALLBRW"  LEFT;
                 ACTION  NIL
         DEFINE BUTTON aBtnMenu[6] OF oBar PROMPT "Stampa" RESOURCE "PRN_SMALLBRW"  LEFT;
                 ACTION  NIL

           case nbar = 2
                 DEFINE BUTTON aBtnMenu[1] OF oBar PROMPT "Elimina" RESOURCE "CAN_SMALLBRW"  LEFT;
                 ACTION  NIL
               DEFINE BUTTON aBtnMenu[2] OF oBar PROMPT "Stampa" RESOURCE "PRN_SMALLBRW"  LEFT;
                 ACTION  NIL


      endcase
    return nil
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
User avatar
Antonio Linares
Site Admin
Posts: 42716
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 93 times
Been thanked: 103 times
Contact:

Re: btnbmp activated when selecting a record

Post by Antonio Linares »

You are creating a button here with no Bar created already:

Code: Select all | Expand

case nbar = 1
         aBtnMenu := array(6)
         DEFINE BUTTON aBtnMenu[1] OF oBar PROMPT "Nuovo" RESOURCE "NEW_SMALLBRW"  LEFT;
                 ACTION  NIL
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

Re: btnbmp activated when selecting a record

Post by Silvio.Falconi »

Antonio Linares wrote: Sat Mar 08, 2025 12:44 pm You are creating a button here with no Bar created already:

Code: Select all | Expand

case nbar = 1
         aBtnMenu := array(6)
         DEFINE BUTTON aBtnMenu[1] OF oBar PROMPT "Nuovo" RESOURCE "NEW_SMALLBRW"  LEFT;
                 ACTION  NIL
No Antonio, Please see barchange.prg (of Cristobal)
I wish make the same only I have the buttonbar at x,y

Code: Select all | Expand

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

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

      oBar:=Tbar():NewAt( 100, 10, 450, 22, 90, 24, oDlg, .f.,;
                 , , .t., .f., .f., .t., .f., ;
                 , , , , ,  .t.)


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

  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


make me this error

Code: Select all | Expand

 Error occurred at: 03/08/25, 16:12:24
   Error description: Error BASE/1004  No exported method: ISKINDOF
   Args:
     [   1] = U   
     [   2] = C   TBAR

Stack Calls
===========
   Called from: .\source\classes\bar.prg => ISKINDOF( 0 )
   Called from: .\source\classes\btnbmp.prg => TBTNBMP:NEWBAR( 504 )
   Called from: test.prg => BTNBAR( 71 )

If you use DEFINE BUTTONBAR oBar OF oDlg SIZE 80,70 TOP NOBORDER 2015 run ok

if you use @ 100,10 BUTTONBAR oBar SIZE 450, 22 BUTTONSIZE 90, 24 OF oDlg NOT run

I tried also with

Code: Select all | Expand

 oBar:=Tbar():NewAt( 100, 10, 450, 22, 90, 24, oDlg, .f.,;
                 , , .t., .f., .f., .t., .f., ;
                 , aGrad, , , ,  .t.)
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
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

Re: btnbmp activated when selecting a record

Post by Silvio.Falconi »

I found on this forum a solution of Nageswarao but I notice a flash on buttonbar when the buttonbar is changed


Image



Code: Select all | Expand

#include "fivewin.ch"

function Main()

   local oDlg, oBrw, oBar1, oBar2, aRow, aData := Array( 8, 6 )

   for each aRow in aData
      AEval( aRow, { |u,i| aRow[ i ] := HB_RandomInt( 100,500 ) } )
   next

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL

   @  20, 20 XBROWSE oBrw SIZE 480,200 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS CELL LINES NOBORDER

   oBrw:CreateFromCode()

   oDlg:bInit := <||

       oBar1:= TBar():NewAt(  oBrw:nbottom+1, oBrw:nLeft, oBrw:nWidth-120, 25, 80, 25, oDlg, .f.,;
              , , .F., .f., .f., .t., .f., ;
              , , , , , .t. )

      oBar1:l2013 := .t.

      DEFINE BUTTON OF oBar1 PROMPT "ONE" CENTER
      DEFINE BUTTON OF oBar1 PROMPT "TWO" CENTER
      DEFINE BUTTON OF oBar1 PROMPT "THREE" CENTER

       oBar1:bClrGrad := { | lPressed | If( ! lPressed,;
                 { { 1, RGB( 250,250,245), RGB( 250,250,245)} },;
                 { { 1, RGB( 245,245,235), RGB( 245,245,235)} } ) }

      oBar1:Hide()

       oBar2:= TBar():NewAt(  oBrw:nbottom+1, oBrw:nLeft, oBrw:nWidth-120, 25, 80, 25, oDlg, .f.,;
              , , .F., .f., .f., .t., .f., ;
              , , , , , .t. )
      oBar2:l2013 := .t.

      DEFINE BUTTON OF oBar2 PROMPT "JAN" CENTER
      DEFINE BUTTON OF oBar2 PROMPT "FEB" CENTER
      DEFINE BUTTON OF oBar2 PROMPT "MARCH" CENTER
        oBar2:bClrGrad := { | lPressed | If( ! lPressed,;
                 { { 1, RGB( 250,250,245), RGB( 250,250,245)} },;
                 { { 1, RGB( 245,245,235), RGB( 245,245,235)} } ) }
      return nil
      >

   @ 280, 20 BUTTON "FIRST BAR" SIZE 150,40 PIXEL OF oDlg ;
      WHEN oBar2:lVisible ACTION ( oBar2:Hide(), oBar1:Show() )

   @ 280,200 BUTTON "SECOND BAR" SIZE 150,40 PIXEL OF oDlg ;
      WHEN oBar1:lVisible ACTION ( oBar1:Hide(), oBar2:Show() )

   ACTIVATE DIALOG oDlg CENTERED

return nil

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
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

Re: btnbmp activated when selecting a record

Post by Silvio.Falconi »

perhaps I reolved with the sample of Rao

Image

also the background of bars are not the same of odlg
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
Post Reply