Dynamic button on buttonbar

Dynamic button on buttonbar

Postby TimStone » Wed Jul 26, 2017 9:27 pm

I have a dialog with multiple folders. Each has a button bar. One of the folders has an xbrowse. As I move up and down the browse rows, I want one of the buttons to be shown based on the value of the highlighted record.

For example, there are two buttons: ADD MEMBER
If the person highlighted is registered in a program, indicated by a field in their record, then I want the MEMBER button to show. If not, then the ADD button needs to show.
The button is one of many displayed on the button bar assigned to the folder.

Also, I can work with an alternative. On the dialog, when the change occurs in xbrowse ( to a different record ) the values shown in the edit fields of the dialogs ( not on the xbrowse ) also are updated to reflect the highlighted record. I can display the button on there and change it according to the status of the highlighted record . I could just display the image but it needs to have an action take place when it is pressed ....

Suggestions will be appreciated.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Dynamic button on buttonbar

Postby nageswaragunupudi » Thu Jul 27, 2017 12:47 pm

Please try this sample. For this test, I have used customer.dbf in fwh\samples folder and used FIELD->MARRIED instead of Member/AddMember. But the principle is the same.

Upto version FWH17.06, prompt changes (Married/Single) when browse row is changed but bitmap does not change.

Please wait for a few days and run the same sample with FWH 17.07. Bitmap also change depending on the value of FIELD->MARRIED. This should work for you.

Code: Select all  Expand view

#include "fivewin.ch"

function Main()

   local oDlg, oBar, oBtn, oBrw

   USE CUSTOMER

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL
   DEFINE BUTTONBAR oBar OF oDlg SIZE 64,48 2007 GDIP

   DEFINE BUTTON oBtn OF oBar ;
      FILE "\fwh\bitmaps\user.bmp", "\fwh\bitmaps\users.bmp" ;
      PROMPT { || If( CUSTOMER->MARRIED, "Married", "Single" ) } ;
      ACTION If( CUSTOMER->MARRIED, MsgInfo( "MARRIED" ), MsgInfo( "SINGLE" ) )

   if Val( HB_ATokens( FWVERSION )[ 2 ] ) > 17.06
      oBtn:bBmpNo := { || If( CUSTOMER->MARRIED, 2, 1 ) }
   endif

   @ 50,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" ;
      COLUMNS "FIRST","CITY","MARRIED","AGE" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :Married:SetCheck( nil, .t. )
      :bChange       := { || oBar:Refresh() }
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
 
Regards

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

Re: Dynamic button on buttonbar

Postby TimStone » Thu Jul 27, 2017 2:26 pm

OK ...

If instead of a button on the button bar, I decide to display a bitmap on a dialog. I want to display the bitmap depending on a value in the record highlighted in the browse. I've done this with text, but not a bitmap. What code would you suggest ?

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 86 guests