button on buttonbar

button on buttonbar

Postby Silvio.Falconi » Fri Jan 14, 2022 9:11 am

the button of buttonbar is disabled but not is on different color

Image

I make oBtnB:Disable() it is disabled but not change colors
I tried and working with DEFINE BUTTONBAR ::oBar OF ::oWinMain _3D 2015
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: 7063
Joined: Thu Oct 18, 2012 7:17 pm

Re: button on buttonbar

Postby karinha » Fri Jan 14, 2022 4:01 pm

Code: Select all  Expand view  RUN

// \samples\ADORICK.PRG

// Incremental Search

#include "FiveWin.ch"
#include "Xbrowse.ch"

STATIC oWnd, oBar, lOK, lOk1, oWndChild, oLbx
STATIC cLname, oLname, oFname, cFname, oFontB
STATIC lLigaBtnBar  // or MEMVAR or PUBLIC -> Silvio!

// -------------
FUNCTION Main()

   LOCAL catNewDB, xProvider, cFile, aDir, dExe, cDefa, mStart
   LOCAL oCn, cSql, oErr, oRsCust, cLOGIN, Saying, xLogin, cRights
   LOCAL cTitle, oButt1, oButt2, nYear, nScr1, nScr2, xMessage, cRdd
   LOCAL xSOURCE

   PUBLIC xCONNECT

   lOK  := .F.
   lLigaBtnBar := .F.

   // -- get timestamp on .exe //

   cFILE := GetModuleFileName( GetInstance() )
   aDIR  := Directory( cFILE )
   dEXE  := aDIR[ 1 ][ 3 ]

   // where .exe started from is default directory //

   mSTART := RAt( "\", cFILE )
   cDEFA  := SubStr( cFILE, 1, mSTART - 1 )

   aDIR := NIL
   SET DEFA TO ( cDEFA )

   SET DELETED ON
   SET CENTURY ON
   SET 3DLOOK on

   nYEAR := ( Year( Date() ) - 30 )
   SET EPOCH TO ( nYEAR )

   REQUEST DBFCDX
   rddsetdefault ( "
DBFCDX" )

   nSCR1 := GetSysMetrics( 0 )
   nSCR2 := GetSysMetrics( 1 )

   xPROVIDER := "
Microsoft.Jet.OLEDB.4.0"
   xSOURCE   := cDEFA + "
\Rick.mdb"
   cRDD      := xPROVIDER + "
-- " + xSOURCE

   // global connection string
   xCONNECT := 'Provider=' + xPROVIDER + ';Data Source=' + xSOURCE

   IF .NOT. File( cDefa + "
\Rick.mdb" )

      FErase( cDefa + "
\Rick.mdb" )

      // create the adox object
      Try
         catNewDB := CreateObject( "
ADOX.Catalog" )
      Catch
         MsgInfo( "
Could not Create ADOX object" )
         Return( .F. )
      End try

      // create the table Rick.mdb
      Try
         catNewDB:Create( 'Provider=' + xProvider + ';Data Source=' + xSource + ';Jet OLEDB:Engine Type=5' )
      Catch
         MsgInfo( "
Could not create the table " + xSource )
         Return( .F. )
      End Try

      Try
        oCn  := CREATEOBJECT( "
ADODB.Connection" )
      Catch
         MsgInfo( "
Could not create the ADO object for connection" )
      End Try

      TRY
         oCn:Open( xCONNECT )
      CATCH oErr
         MsgInfo( "
Could not open a Connection to Database " + xSource )
         RETURN( .F. )
      END TRY


      cSQL := "
CREATE TABLE CUSTOMER"
      cSQL += "
( "
      cSQL += "
[CUSTOMEREID] char(18) NOT NULL, "
      cSQL += "
[LAST NAME] char(30) NULL, "
      cSQL += "
[FIRST NAME] char(30) NULL, "
      cSQL += "
[MID INIT] char(30) NULL, "
      cSQL += "
[ADDRESS1] char(30) NULL, "
      cSQL += "
[CITY] char(30) NULL, "
      cSQL += "
[STATE] char(30) NULL, "
      cSQL += "
CONSTRAINT PK_USERINFO PRIMARY KEY ( CUSTOMEREID )"
      cSQL += "
)"

      Try
         oCn:Execute( cSQL )
      Catch
         MsgInfo( "
Table CUSTOMER Failed" )
         Return( .F. )
      End try

      oCn:Close()
      oCn := nil

   ENDIF

   xLOGIN := Upper( WNetGetuser() ) + Space( 8 ) // fivewin
   xLOGIN := SubStr( xLOGIN, 1, 8 )

   oRsCust := TOleAuto():New( "
ADODB.Recordset" )
   oRsCust:CursorType     := 1        // opendkeyset
   oRsCust:CursorLocation := 3        // local cache
   oRsCust:LockType       := 3        // lockoportunistic

   // check for very first user

   cSQL := "
SELECT * FROM CUSTOMER"

   TRY
      oRsCust:Open( cSQL, xCONNECT )
   CATCH oErr
      MsgInfo( "
Error in Opening CUSTOMER table here" )

      RETURN( .F. )
   END TRY

   IF oRsCust:eof

      oRsCust:AddNew()
      oRsCust:Fields( "
CustomerEid" ):Value  := "011111111111111111"
      oRsCust:Fields( "
Last Name" ):Value    := "Lipkin"
      oRsCust:Fields( "
First Name" ):Value   := "Richard"
      oRsCust:Fields( "
Mid Init" ):Value     := "M"
      oRsCust:Fields( "
Address1" ):Value     := "123 Anywhere"
      oRsCust:Fields( "
City" ):Value         := "Columbia"
      oRsCust:Fields( "
State" ):Value        := "SC"
      oRsCust:Update()

      oRsCust:AddNew()
      oRsCust:Fields( "
CustomerEid" ):Value  := "011111111111111112"
      oRsCust:Fields( "
Last Name" ):Value    := "Lipinsky"
      oRsCust:Fields( "
First Name" ):Value   := "Jason"
      oRsCust:Fields( "
Mid Init" ):Value     := "S"
      oRsCust:Fields( "
Address1" ):Value     := "123 Arborgate"
      oRsCust:Fields( "
City" ):Value         := "Columbia"
      oRsCust:Fields( "
State" ):Value        := "SC"
      oRsCust:Update()

      oRsCust:AddNew()
      oRsCust:Fields( "
CustomerEid" ):Value    := "011111111111111113"
      oRsCust:Fields( "
Last Name" ):Value    := "Lipkin"
      oRsCust:Fields( "
First Name" ):Value   := "Beth"
      oRsCust:Fields( "
Mid Init" ):Value     := "  "
      oRsCust:Fields( "
Address1" ):Value     := "123 Lake Murray Blvd"
      oRsCust:Fields( "
City" ):Value         := "Lexington"
      oRsCust:Fields( "
State" ):Value        := "SC"
      oRsCust:Update()

      oRsCust:AddNew()
      oRsCust:Fields( "
CustomerEid" ):Value    := "011111111111111114"
      oRsCust:Fields( "
Last Name" ):Value    := "Lizzarous"
      oRsCust:Fields( "
First Name" ):Value   := "Tim"
      oRsCust:Fields( "
Mid Init" ):Value     := "J"
      oRsCust:Fields( "
Address1" ):Value     := "456 Broad River"
      oRsCust:Fields( "
City" ):Value         := "Irmo"
      oRsCust:Fields( "
State" ):Value        := "SC"
      oRsCust:Update()

   ENDIF

   oFontB  := TFont():New( "
Ms Sans Serif",, - 6, .F., .T.,,,, .F. )
   cRIGHTS := "
(RWS)"

   xMESSAGE :=  "
User  " + xLOGIN + "    Rights  " + cRIGHTS +        ;
                "
    Default= " + cDEFA + "      Rdd= " + cRDD +     ;
                "
    Revision  " + DToC( dEXE ) + ;
                "
 -r" + Str( nSCR1, 4 ) + " x " + Str( nSCR2, 4 )

   cTitle := "
Test Incremental Search with ON CHANGE"

   DEFINE WINDOW oWnd  ;
      TITLE cTITLE     ;
      MENU BuildMenu() ;
      MDI

   DEFINE BUTTONBAR oBar OF oWnd SIZE 65, 70 3DLOOK 2015

   oBar:SetColor( 0 )

   DEFINE BUTTON oButt1 OF oBar  ;
      MESSAGE "
Customer Information" ;
      ACTION _Custview( "
A", oWnd, oButt1, oButt2 ) ;
      PROMPT "
Customer Info"                        ;
      WHEN( lLigaBtnBar )

   DEFINE BUTTON oButt2 OF oBar ;
      MESSAGE "
Close Application" ;
      ACTION ( oWnd:End() ) ;
      PROMPT "
Quit"

   SET MESSAGE OF oWnd     ;
      TO xMESSAGE CLOCK 2015

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      VALID ( iif( !lOK, ExitPgm( .T. ), .F. ) )

RETURN( NIL )

STATIC FUNCTION BuildMenu()

   LOCAL oMENU, cDEFA

   cDEFA := Set( 7 )


   MENU oMenu 2015

   MENUITEM "
Login..."   // ;

      MENUITEM "
&About..."

   MENUITEM "
&Quit"          ;
      MESSAGE "
Close this program";
      ACTION oWND:END()

   ENDMENU

RETURN( oMenu )

STATIC FUNCTION ExitPgm( lCLEAN )

   LOCAL lOK3

   lOK3  := .F.

   IF lCLEAN = .T.

      lOK3 := .T.
      lOK  := .T.

      SET RESOURCES TO

   ENDIF

RETURN( lOK3 )

// -------------------------------
STATIC FUNC _Custview( cMODE, oWnd, oBtn1, oBtn2 )

   LOCAL SAYING, cDEFA, oErr
   LOCAL cTITLE
   LOCAL oIco, oFld, oCust
   LOCAL oRsCust, cSql

   lOK1  := .F.

   cSQL := "
SELECT * from CUSTOMER order by [Last Name]"

   oRsCust := TOleAuto():New( "
ADODB.Recordset" )
   oRsCust:CursorType     := 1        // opendkeyset
   oRsCust:CursorLocation := 3        // local cache
   oRsCust:LockType       := 3        // lockoportunistic

   TRY
      oRsCust:Open( cSQL, xCONNECT )
   CATCH oErr
      MsgInfo( "
Error in Opening CUSTOMER table" )

      RETURN( .F. )
   END TRY

   SysReFresh()

   cTITLE := "
Customer Maintenance"

   DO CASE
   CASE cMODE = "
E"
      cTITLE := "
Customer Maintenance  EDIT"
   CASE cMODE = "
A"
      cTITLE := "
Customer Maintenance   ADD"
   CASE cMODE = "
V"
   cTITLE := "
Customer Maintenance  VIEW"
   ENDCASE

   oBtn1:Disable()
   oBtn2:Disable()

   DEFINE WINDOW oWndChild            ;
      MDICHILD                    ;
      FROM 0, 0 TO 32, 100          ;
      OF oWnd                     ;
      TITLE cTITLE

   DEFINE DIALOG oCust RESOURCE "
CUSTOMER" of oWndChild


   REDEFINE FOLDEREX oFld ID 109 of oCust PROMPT "
Billing Information", "Service Address";
      DIALOGS "
CUSTVIEW", "SERVVIEW"

   Folder_1( cMode, oWnd, oRsCust, oFld ) // Custview folder


   ACTIVATE DIALOG oCust  NOWAIT ;
      ON INIT ( oCust:Move( 0, 0 ) );
      VALID( !GETKEYSTATE( 27 ) )


   ACTIVATE WINDOW oWndChild ;
      ON INIT oWndChild:SetSize( oCust:nWidth, oCust:nHeight, .T. );
      VALID ( iif( !lOK1, ExitPgm1( .T., oWndChild, oRsCust, oBtn1, oBtn2 ), .F. ) )

RETURN( NIL )

// ---------- FOLDER-PAGE 1
STATIC FUNC FOLDER_1( cMode, oWnd, oRsCust, oFld )

   LOCAL oSay1, oSay2, oSay3, oSay4, oCol

   cLname := Space( 50 )
   cFname := Space( 50 )

   REDEFINE SAY oSay1 PROMPT "
Customer Type" ID 110 OF oFld:aDialogs[ 1 ] UPDATE

   oSay1:SetFont( oFontB )

   REDEFINE SAY oSay2 PROMPT "
Customer Id" ID 111 OF oFld:aDialogs[ 1 ] UPDATE

   oSay2:SetFont( oFontB )

   REDEFINE SAY oSay3 PROMPT "
Company or Last Name" ID 112 OF oFld:aDialogs[ 1 ] UPDATE

   oSay3:SetFont( oFontB )

   REDEFINE SAY oSay4 PROMPT "
First Name" ID 113 OF oFld:aDialogs[ 1 ] UPDATE

   oSay4:SetFont( oFontB )

   REDEFINE GET oLname VAR cLname ID 153 of oFld:aDialogs[ 1 ] ;
      ON CHANGE ( _Isearch( oLname, cLname, oLbx, oRsCust ) ) UPDATE

   REDEFINE GET oFname VAR cFname ID 154 of oFld:aDialogs[ 1 ] UPDATE

   REDEFINE xBROWSE oLBX           ;
      RECORDSET oRsCust            ;
      COLUMNS "
CUSTOMEREID"        ;
      COLSIZES 50                  ;
      HEADERS "
Cust Id"            ;
      ID 172 of oFld:aDialogs[ 1 ] ;
      AUTOCOLS LINES

   ADD oCol TO oLbx AT 1 DATA {| x | x := _ChkName( oRsCust:Fields( "
Last Name" ):Value, ;
      oRsCust:Fields( "
First Name" ):Value, ;
      oRsCust:Fields( "
Mid Init" ):Value ) };
      HEADER "
Last Name or Company" size 190


   ADD oCol TO oLbx AT 2 DATA {| x | x := _ChkAdd( oRsCust:Fields( "
Address1" ):Value, ;
      oRsCust:Fields( "
City" ):Value, ;
      oRsCust:Fields( "
State" ):Value ) };
      HEADER "
Address" size 200

RETURN( NIL )
// ----------------------------
STATIC FUNC _ChkName( cLast, cFirst, cMiddle )

   LOCAL cName

   cName := SubStr( "
Unk" + Space( 45 ), 1, 45 )

   IF cMiddle = "
"
      IF cFirst = "
" .OR. Empty( cFirst )
         cName = SubStr( AllTrim( cLast ) + Space( 45 ), 1, 45 )
      ELSE
         cName := SubStr( AllTrim( cLast ) + "
, " + AllTrim( cFirst ) + Space( 45 ), 1, 45 )
      ENDIF
   ELSE
      IF cFirst = "
" .OR. Empty( cFirst )
         cName = SubStr( AllTrim( cLast ) + Space( 45 ), 1, 45 )
      ELSE
         cName := SubStr( AllTrim( cLast ) + "
, " + AllTrim( cFirst ) + " " + ;
            AllTrim( cMiddle ) + Space( 45 ), 1, 45 )
      ENDIF
   ENDIF

Return( cName )

// -------------------------------
STATIC FUNC _ChkAdd( cAddress, cCity, cState )

   LOCAL cName

   cName := if( cAddress = "
" .OR. Empty( cAddress ), " ", AllTrim( cAddress ) ) + " " + ;
      if( cCity = "
" .OR. Empty( cCity ), " ", AllTrim( cCity ) ) + " " + ;
      if( cState = "
" .OR. Empty( cState ), " ", AllTrim( cState ) )

   cName := SubStr( AllTrim( cName ) + Space( 45 ), 1, 45 )

Return( cName )

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

STATIC FUNC _Isearch( oLname1, cLname1, oBrw, oRsCust )

   cLname1 = AllTrim( oLName1:GetText() )

   IF Empty( cLname1 )
      RETURN .T.
   ENDIF

   oRsCust:FILTER := "
[Last Name] like '" + cLname1 + "%'"

   oBrw:ReFresh()

RETURN .T.
// -------------------------------
STATIC FUNCTION ExitPgm1( lCLEAN, oWndchild, oRsCust, oBtn1, oBtn2 )

   LOCAL cDEFA, lOK3

   cDEFA := Set( 7 )

   IF lCLEAN = .T.
      lOK1  := .T.

      oRsCust:CLose()
      oWndChild:End()

      oBtn1:Enable()
      oBtn2:Enable()

   ENDIF

RETURN( lOK1 )

// -- end
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: button on buttonbar

Postby Silvio.Falconi » Sat Jan 15, 2022 8:18 am

karinha wrote:
Code: Select all  Expand view  RUN

// \samples\ADORICK.PRG

// Incremental Search

#include "FiveWin.ch"
#include "Xbrowse.ch"

STATIC oWnd, oBar, lOK, lOk1, oWndChild, oLbx
STATIC cLname, oLname, oFname, cFname, oFontB
STATIC lLigaBtnBar  // or MEMVAR or PUBLIC -> Silvio!

// -------------
FUNCTION Main()

   LOCAL catNewDB, xProvider, cFile, aDir, dExe, cDefa, mStart
   LOCAL oCn, cSql, oErr, oRsCust, cLOGIN, Saying, xLogin, cRights
   LOCAL cTitle, oButt1, oButt2, nYear, nScr1, nScr2, xMessage, cRdd
   LOCAL xSOURCE

   PUBLIC xCONNECT

   lOK  := .F.
   lLigaBtnBar := .F.

   // -- get timestamp on .exe //

   cFILE := GetModuleFileName( GetInstance() )
   aDIR  := Directory( cFILE )
   dEXE  := aDIR[ 1 ][ 3 ]

   // where .exe started from is default directory //

   mSTART := RAt( "\", cFILE )
   cDEFA  := SubStr( cFILE, 1, mSTART - 1 )

   aDIR := NIL
   SET DEFA TO ( cDEFA )

   SET DELETED ON
   SET CENTURY ON
   SET 3DLOOK on

   nYEAR := ( Year( Date() ) - 30 )
   SET EPOCH TO ( nYEAR )

   REQUEST DBFCDX
   rddsetdefault ( "
DBFCDX" )

   nSCR1 := GetSysMetrics( 0 )
   nSCR2 := GetSysMetrics( 1 )

   xPROVIDER := "
Microsoft.Jet.OLEDB.4.0"
   xSOURCE   := cDEFA + "
\Rick.mdb"
   cRDD      := xPROVIDER + "
-- " + xSOURCE

   // global connection string
   xCONNECT := 'Provider=' + xPROVIDER + ';Data Source=' + xSOURCE

   IF .NOT. File( cDefa + "
\Rick.mdb" )

      FErase( cDefa + "
\Rick.mdb" )

      // create the adox object
      Try
         catNewDB := CreateObject( "
ADOX.Catalog" )
      Catch
         MsgInfo( "
Could not Create ADOX object" )
         Return( .F. )
      End try

      // create the table Rick.mdb
      Try
         catNewDB:Create( 'Provider=' + xProvider + ';Data Source=' + xSource + ';Jet OLEDB:Engine Type=5' )
      Catch
         MsgInfo( "
Could not create the table " + xSource )
         Return( .F. )
      End Try

      Try
        oCn  := CREATEOBJECT( "
ADODB.Connection" )
      Catch
         MsgInfo( "
Could not create the ADO object for connection" )
      End Try

      TRY
         oCn:Open( xCONNECT )
      CATCH oErr
         MsgInfo( "
Could not open a Connection to Database " + xSource )
         RETURN( .F. )
      END TRY


      cSQL := "
CREATE TABLE CUSTOMER"
      cSQL += "
( "
      cSQL += "
[CUSTOMEREID] char(18) NOT NULL, "
      cSQL += "
[LAST NAME] char(30) NULL, "
      cSQL += "
[FIRST NAME] char(30) NULL, "
      cSQL += "
[MID INIT] char(30) NULL, "
      cSQL += "
[ADDRESS1] char(30) NULL, "
      cSQL += "
[CITY] char(30) NULL, "
      cSQL += "
[STATE] char(30) NULL, "
      cSQL += "
CONSTRAINT PK_USERINFO PRIMARY KEY ( CUSTOMEREID )"
      cSQL += "
)"

      Try
         oCn:Execute( cSQL )
      Catch
         MsgInfo( "
Table CUSTOMER Failed" )
         Return( .F. )
      End try

      oCn:Close()
      oCn := nil

   ENDIF

   xLOGIN := Upper( WNetGetuser() ) + Space( 8 ) // fivewin
   xLOGIN := SubStr( xLOGIN, 1, 8 )

   oRsCust := TOleAuto():New( "
ADODB.Recordset" )
   oRsCust:CursorType     := 1        // opendkeyset
   oRsCust:CursorLocation := 3        // local cache
   oRsCust:LockType       := 3        // lockoportunistic

   // check for very first user

   cSQL := "
SELECT * FROM CUSTOMER"

   TRY
      oRsCust:Open( cSQL, xCONNECT )
   CATCH oErr
      MsgInfo( "
Error in Opening CUSTOMER table here" )

      RETURN( .F. )
   END TRY

   IF oRsCust:eof

      oRsCust:AddNew()
      oRsCust:Fields( "
CustomerEid" ):Value  := "011111111111111111"
      oRsCust:Fields( "
Last Name" ):Value    := "Lipkin"
      oRsCust:Fields( "
First Name" ):Value   := "Richard"
      oRsCust:Fields( "
Mid Init" ):Value     := "M"
      oRsCust:Fields( "
Address1" ):Value     := "123 Anywhere"
      oRsCust:Fields( "
City" ):Value         := "Columbia"
      oRsCust:Fields( "
State" ):Value        := "SC"
      oRsCust:Update()

      oRsCust:AddNew()
      oRsCust:Fields( "
CustomerEid" ):Value  := "011111111111111112"
      oRsCust:Fields( "
Last Name" ):Value    := "Lipinsky"
      oRsCust:Fields( "
First Name" ):Value   := "Jason"
      oRsCust:Fields( "
Mid Init" ):Value     := "S"
      oRsCust:Fields( "
Address1" ):Value     := "123 Arborgate"
      oRsCust:Fields( "
City" ):Value         := "Columbia"
      oRsCust:Fields( "
State" ):Value        := "SC"
      oRsCust:Update()

      oRsCust:AddNew()
      oRsCust:Fields( "
CustomerEid" ):Value    := "011111111111111113"
      oRsCust:Fields( "
Last Name" ):Value    := "Lipkin"
      oRsCust:Fields( "
First Name" ):Value   := "Beth"
      oRsCust:Fields( "
Mid Init" ):Value     := "  "
      oRsCust:Fields( "
Address1" ):Value     := "123 Lake Murray Blvd"
      oRsCust:Fields( "
City" ):Value         := "Lexington"
      oRsCust:Fields( "
State" ):Value        := "SC"
      oRsCust:Update()

      oRsCust:AddNew()
      oRsCust:Fields( "
CustomerEid" ):Value    := "011111111111111114"
      oRsCust:Fields( "
Last Name" ):Value    := "Lizzarous"
      oRsCust:Fields( "
First Name" ):Value   := "Tim"
      oRsCust:Fields( "
Mid Init" ):Value     := "J"
      oRsCust:Fields( "
Address1" ):Value     := "456 Broad River"
      oRsCust:Fields( "
City" ):Value         := "Irmo"
      oRsCust:Fields( "
State" ):Value        := "SC"
      oRsCust:Update()

   ENDIF

   oFontB  := TFont():New( "
Ms Sans Serif",, - 6, .F., .T.,,,, .F. )
   cRIGHTS := "
(RWS)"

   xMESSAGE :=  "
User  " + xLOGIN + "    Rights  " + cRIGHTS +        ;
                "
    Default= " + cDEFA + "      Rdd= " + cRDD +     ;
                "
    Revision  " + DToC( dEXE ) + ;
                "
 -r" + Str( nSCR1, 4 ) + " x " + Str( nSCR2, 4 )

   cTitle := "
Test Incremental Search with ON CHANGE"

   DEFINE WINDOW oWnd  ;
      TITLE cTITLE     ;
      MENU BuildMenu() ;
      MDI

   DEFINE BUTTONBAR oBar OF oWnd SIZE 65, 70 3DLOOK 2015

   oBar:SetColor( 0 )

   DEFINE BUTTON oButt1 OF oBar  ;
      MESSAGE "
Customer Information" ;
      ACTION _Custview( "
A", oWnd, oButt1, oButt2 ) ;
      PROMPT "
Customer Info"                        ;
      WHEN( lLigaBtnBar )

   DEFINE BUTTON oButt2 OF oBar ;
      MESSAGE "
Close Application" ;
      ACTION ( oWnd:End() ) ;
      PROMPT "
Quit"

   SET MESSAGE OF oWnd     ;
      TO xMESSAGE CLOCK 2015

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      VALID ( iif( !lOK, ExitPgm( .T. ), .F. ) )

RETURN( NIL )

STATIC FUNCTION BuildMenu()

   LOCAL oMENU, cDEFA

   cDEFA := Set( 7 )


   MENU oMenu 2015

   MENUITEM "
Login..."   // ;

      MENUITEM "
&About..."

   MENUITEM "
&Quit"          ;
      MESSAGE "
Close this program";
      ACTION oWND:END()

   ENDMENU

RETURN( oMenu )

STATIC FUNCTION ExitPgm( lCLEAN )

   LOCAL lOK3

   lOK3  := .F.

   IF lCLEAN = .T.

      lOK3 := .T.
      lOK  := .T.

      SET RESOURCES TO

   ENDIF

RETURN( lOK3 )

// -------------------------------
STATIC FUNC _Custview( cMODE, oWnd, oBtn1, oBtn2 )

   LOCAL SAYING, cDEFA, oErr
   LOCAL cTITLE
   LOCAL oIco, oFld, oCust
   LOCAL oRsCust, cSql

   lOK1  := .F.

   cSQL := "
SELECT * from CUSTOMER order by [Last Name]"

   oRsCust := TOleAuto():New( "
ADODB.Recordset" )
   oRsCust:CursorType     := 1        // opendkeyset
   oRsCust:CursorLocation := 3        // local cache
   oRsCust:LockType       := 3        // lockoportunistic

   TRY
      oRsCust:Open( cSQL, xCONNECT )
   CATCH oErr
      MsgInfo( "
Error in Opening CUSTOMER table" )

      RETURN( .F. )
   END TRY

   SysReFresh()

   cTITLE := "
Customer Maintenance"

   DO CASE
   CASE cMODE = "
E"
      cTITLE := "
Customer Maintenance  EDIT"
   CASE cMODE = "
A"
      cTITLE := "
Customer Maintenance   ADD"
   CASE cMODE = "
V"
   cTITLE := "
Customer Maintenance  VIEW"
   ENDCASE

   oBtn1:Disable()
   oBtn2:Disable()

   DEFINE WINDOW oWndChild            ;
      MDICHILD                    ;
      FROM 0, 0 TO 32, 100          ;
      OF oWnd                     ;
      TITLE cTITLE

   DEFINE DIALOG oCust RESOURCE "
CUSTOMER" of oWndChild


   REDEFINE FOLDEREX oFld ID 109 of oCust PROMPT "
Billing Information", "Service Address";
      DIALOGS "
CUSTVIEW", "SERVVIEW"

   Folder_1( cMode, oWnd, oRsCust, oFld ) // Custview folder


   ACTIVATE DIALOG oCust  NOWAIT ;
      ON INIT ( oCust:Move( 0, 0 ) );
      VALID( !GETKEYSTATE( 27 ) )


   ACTIVATE WINDOW oWndChild ;
      ON INIT oWndChild:SetSize( oCust:nWidth, oCust:nHeight, .T. );
      VALID ( iif( !lOK1, ExitPgm1( .T., oWndChild, oRsCust, oBtn1, oBtn2 ), .F. ) )

RETURN( NIL )

// ---------- FOLDER-PAGE 1
STATIC FUNC FOLDER_1( cMode, oWnd, oRsCust, oFld )

   LOCAL oSay1, oSay2, oSay3, oSay4, oCol

   cLname := Space( 50 )
   cFname := Space( 50 )

   REDEFINE SAY oSay1 PROMPT "
Customer Type" ID 110 OF oFld:aDialogs[ 1 ] UPDATE

   oSay1:SetFont( oFontB )

   REDEFINE SAY oSay2 PROMPT "
Customer Id" ID 111 OF oFld:aDialogs[ 1 ] UPDATE

   oSay2:SetFont( oFontB )

   REDEFINE SAY oSay3 PROMPT "
Company or Last Name" ID 112 OF oFld:aDialogs[ 1 ] UPDATE

   oSay3:SetFont( oFontB )

   REDEFINE SAY oSay4 PROMPT "
First Name" ID 113 OF oFld:aDialogs[ 1 ] UPDATE

   oSay4:SetFont( oFontB )

   REDEFINE GET oLname VAR cLname ID 153 of oFld:aDialogs[ 1 ] ;
      ON CHANGE ( _Isearch( oLname, cLname, oLbx, oRsCust ) ) UPDATE

   REDEFINE GET oFname VAR cFname ID 154 of oFld:aDialogs[ 1 ] UPDATE

   REDEFINE xBROWSE oLBX           ;
      RECORDSET oRsCust            ;
      COLUMNS "
CUSTOMEREID"        ;
      COLSIZES 50                  ;
      HEADERS "
Cust Id"            ;
      ID 172 of oFld:aDialogs[ 1 ] ;
      AUTOCOLS LINES

   ADD oCol TO oLbx AT 1 DATA {| x | x := _ChkName( oRsCust:Fields( "
Last Name" ):Value, ;
      oRsCust:Fields( "
First Name" ):Value, ;
      oRsCust:Fields( "
Mid Init" ):Value ) };
      HEADER "
Last Name or Company" size 190


   ADD oCol TO oLbx AT 2 DATA {| x | x := _ChkAdd( oRsCust:Fields( "
Address1" ):Value, ;
      oRsCust:Fields( "
City" ):Value, ;
      oRsCust:Fields( "
State" ):Value ) };
      HEADER "
Address" size 200

RETURN( NIL )
// ----------------------------
STATIC FUNC _ChkName( cLast, cFirst, cMiddle )

   LOCAL cName

   cName := SubStr( "
Unk" + Space( 45 ), 1, 45 )

   IF cMiddle = "
"
      IF cFirst = "
" .OR. Empty( cFirst )
         cName = SubStr( AllTrim( cLast ) + Space( 45 ), 1, 45 )
      ELSE
         cName := SubStr( AllTrim( cLast ) + "
, " + AllTrim( cFirst ) + Space( 45 ), 1, 45 )
      ENDIF
   ELSE
      IF cFirst = "
" .OR. Empty( cFirst )
         cName = SubStr( AllTrim( cLast ) + Space( 45 ), 1, 45 )
      ELSE
         cName := SubStr( AllTrim( cLast ) + "
, " + AllTrim( cFirst ) + " " + ;
            AllTrim( cMiddle ) + Space( 45 ), 1, 45 )
      ENDIF
   ENDIF

Return( cName )

// -------------------------------
STATIC FUNC _ChkAdd( cAddress, cCity, cState )

   LOCAL cName

   cName := if( cAddress = "
" .OR. Empty( cAddress ), " ", AllTrim( cAddress ) ) + " " + ;
      if( cCity = "
" .OR. Empty( cCity ), " ", AllTrim( cCity ) ) + " " + ;
      if( cState = "
" .OR. Empty( cState ), " ", AllTrim( cState ) )

   cName := SubStr( AllTrim( cName ) + Space( 45 ), 1, 45 )

Return( cName )

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

STATIC FUNC _Isearch( oLname1, cLname1, oBrw, oRsCust )

   cLname1 = AllTrim( oLName1:GetText() )

   IF Empty( cLname1 )
      RETURN .T.
   ENDIF

   oRsCust:FILTER := "
[Last Name] like '" + cLname1 + "%'"

   oBrw:ReFresh()

RETURN .T.
// -------------------------------
STATIC FUNCTION ExitPgm1( lCLEAN, oWndchild, oRsCust, oBtn1, oBtn2 )

   LOCAL cDEFA, lOK3

   cDEFA := Set( 7 )

   IF lCLEAN = .T.
      lOK1  := .T.

      oRsCust:CLose()
      oWndChild:End()

      oBtn1:Enable()
      oBtn2:Enable()

   ENDIF

RETURN( lOK1 )

// -- end




MY source run ok only the BTBMP NOT CHANGE THE COLOR WHEN IS DISABLED !!!!!!
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: 7063
Joined: Thu Oct 18, 2012 7:17 pm

Re: button on buttonbar

Postby Silvio.Falconi » Sat Jan 15, 2022 8:30 am

Please try this small test

Code: Select all  Expand view  RUN
#include "FiveWin.ch"


function Main()
 
   local oWnd,oBar
   local oBtns[1]

   DEFINE WINDOW oWnd TITLE "Test"

      DEFINE BUTTONBAR oBar OF oWnd _3D 2015

   DEFINE BUTTON oBtns[1] FILENAME "blab.bmp" OF oBar NOBORDER ;
      ACTION Test(oBtns[1])

   ACTIVATE WINDOW oWnd
 
return nil


Function test(oBtn)
oBtn:disable()
return nil
 


blab.bmp
Image

rename into .bmp because with png run ok my problem is when it is a bmp
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: 7063
Joined: Thu Oct 18, 2012 7:17 pm

Re: button on buttonbar

Postby karinha » Mon Jan 17, 2022 2:00 pm

Teste completo con .BMP, .JPG y .PNG - Download:

https://mega.nz/file/gN9ECbrQ#C3U5SX0KpXvVIdi6uXMlHLUiIGQ3jv3prlY4MjLz8ok

Silvio, tienes razón con .BMP, el comando Disable() no funciona. Con .JPG y .PNG funciona bien. No sé por qué, tal vez el señor Nages pueda explicarlo.

Silvio, You're right with .BMP the Disable() command doesn't work. With .JPG and .PNG it works fine. I don't know why, maybe Mister Nages can explain.

Code: Select all  Expand view  RUN

// C:\BLAB\BLAB.PRG - By Silvio Falconi.

#include "FiveWin.ch"

STATIC oWnd
STATIC lEnableBtn := .T.

FUNCTION Main()
 
   LOCAL oBar
   LOCAL oBtn := ARRAY(5)

   DEFINE WINDOW oWnd TITLE "Test"

   DEFINE BUTTONBAR oBar OF oWnd _3D 2015

   DEFINE BUTTON oBtn[1] FILENAME ".\blab.png" OF oBar NOBORDER ;
      ACTION( Test( oBtn ) )

   DEFINE BUTTON oBtn[2] FILENAME ".\timao.jpg" OF oBar NOBORDER ;
      ACTION( Return_Image( oBtn ) )

   DEFINE BUTTON oBtn[3] FILENAME ".\Help.bmp" OF oBar NOBORDER ;
      ACTION( Return_Image( oBtn ), oBtn[3]:Refresh() ) WHEN( lEnableBtn )

   DEFINE BUTTON oBtn[4] FILENAME ".\Exit.bmp" OF oBar NOBORDER ;
      ACTION( oWnd:End() )

   ACTIVATE WINDOW oWnd
 
RETURN NIL

FUNCTION Test( oBtn )

   oBtn[1]:Disable()
   oBtn[1]:Refresh()

   oBtn[2]:Enable()
   oBtn[2]:Refresh()

   lEnableBtn := .F.   // no funciona con BMP
   oBtn[3]:Refresh()

RETURN NIL

FUNCTION Return_Image( oBtn )

   oBtn[1]:Enable()
   oBtn[1]:Refresh()

   oBtn[2]:Disable()
   oBtn[2]:Refresh()

   lEnableBtn := .T.  // no funciona con BMP
   oBtn[3]:Refresh()

RETURN NIL

// FIN / END
 


Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: button on buttonbar

Postby karinha » Tue Jan 18, 2022 2:43 pm

me respondo a mi mismo. Sí, funciona con BTNBMP.

I answer myself. Yes it works with BTNBMP.

Code: Select all  Expand view  RUN

// C:\BLAB\BLAB.PRG - By Silvio Falconi.

#include "FiveWin.ch"

STATIC oWnd
STATIC lEnableBtn := .T.

FUNCTION Main()
 
   LOCAL oBar
   LOCAL oBtn := ARRAY(5)

   DEFINE WINDOW oWnd TITLE "Test"

   DEFINE BUTTONBAR oBar OF oWnd _3D 2007 // 2015

   DEFINE BUTTON oBtn[1] FILENAME ".\blab.png" OF oBar NOBORDER ;
      ACTION( Test( oBtn ) )

   DEFINE BUTTON oBtn[2] FILENAME ".\timao.jpg" OF oBar NOBORDER ;
      ACTION( Return_Image( oBtn ) )

   @ 03, 50 BTNBMP oBtn[3] FILENAME ".\Help.bmp" ;
      SIZE 30, 30 OF oBar NOBORDER               ;
      ACTION( Funciona_Con_BTNBMP( oBtn ) ) WHEN( lEnableBtn )

   DEFINE BUTTON oBtn[4] FILENAME ".\Exit.bmp" OF oBar NOBORDER ;
      ACTION( oWnd:End() )

   ACTIVATE WINDOW oWnd
 
RETURN NIL

FUNCTION Test( oBtn )

   oBtn[1]:Disable()
   oBtn[1]:Refresh()

   oBtn[2]:Enable()
   oBtn[2]:Refresh()

   lEnableBtn := .F.   // no funciona con BMP
   oBtn[3]:Refresh()

RETURN NIL

FUNCTION Return_Image( oBtn )

   oBtn[1]:Enable()
   oBtn[1]:Refresh()

   oBtn[2]:Disable()
   oBtn[2]:Refresh()

   lEnableBtn := .T.  // no funciona con BMP
   oBtn[3]:Refresh()

RETURN NIL

FUNCTION Funciona_Con_BTNBMP( oBtn )

   ? [Si, funciona con BTNBMP, *.BMP]

RETURN NIL

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

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