Page 1 of 1

Get...bitmap..action

Posted: Sat Nov 27, 2021 4:28 pm
by Silvio.Falconi
I wish to show mail.bmp when on get there is a cr,if the get is empty the control get must not have the button

I try with this test

Code: Select all | Expand


#include "fivewin.ch"

Function test()
local oDlg,oGet,oFont,oBold
local aGet[1]
local cEmail:=Space(30)

 DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
 DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-14 BOLD

DEFINE DIALOG oDlg SIZE  400,40   PIXEL TRUEPIXEL ;
   COLOR CLR_BLACK,  nRgb( 245,244,234)  FONT oFont  ;
   TITLE "ww"

@ 10, 12 GET aGet[1] VAR cEmail ;
          BITMAP IIF(!Empty(cEMail),"mail.bmp","");
          SIZE 300,24 PIXEL OF oDlg ;
          ACTION Msginfo("Email")  ;
           ON CHANGE  IIF(!Empty(cEMail),;
                          (aGet[1]:oBtn:setfile("mail.bmp"),aGet[1]:oBtn:show()),;
                          aGet[1]:oBtn:Hide())
      aGet[1]:lBtnTransparent := .T.



 Activate DIALOG oDLg center
RETURN NIL

 




I made also

@ 10, 12 GET aGet[1] VAR cEmail ;
BITMAP IIF(!Empty(cEMail),"mail.bmp","");
SIZE 300,24 PIXEL OF oDlg ;
ACTION Msginfo("Email") ;
ON CHANGE cambia(aGET,cEmail)

Function cambia(aGET,cEmail)
IF !Empty(cEMail)
aGet[1]:oBtn:setfile("mail.bmp")
aGet[1]:oBtn:show()
aGet[1]:lBtnTransparent := .T.
else
aGet[1]:oBtn:setfile("")
aGet[1]:oBtn:hide()
aGet[1]:lBtnTransparent := .T.
Endif
aGet[1]:refresh()
RETURN NIL

but it take a buttonbmp instead btnbmp


I think there is a technique to do this because in a dialog I have a lot of get controls that I have to use

Re: Get...bitmap..action

Posted: Sat Nov 27, 2021 10:38 pm
by Jimmy
hi,

does FiveWin have WHEN / VALID for GET :?:

if Yes try this

Code: Select all | Expand

@ 10, 12 GET aGet[1] VAR cEmail WHEN ;
   cambia(aGET,cEmail)
   ...
   ON CHANGE cambia(aGET,cEmail)


Function cambia(aGET,cEmail)
   ...
RETURN .T.  // MUST be .T. for WHEN / VALID

Re: Get...bitmap..action

Posted: Sun Nov 28, 2021 8:00 am
by Otto
Hello Jimmy,
I'm sure you know, but sometimes you don't think about it.

The nice thing about FIVEWIN is that all the source code is available to us.

And as Daniel always says:
our best documentation is the source code

Best regards and have an enjoyable Sunday,
Otto

FWH/source/
classes
function
winapi

Re: Get...bitmap..action

Posted: Mon Nov 29, 2021 11:04 am
by Silvio.Falconi
Otto wrote:Hello Jimmy,
I'm sure you know, but sometimes you don't think about it.

The nice thing about FIVEWIN is that all the source code is available to us.

And as Daniel always says:
our best documentation is the source code

Best regards and have an enjoyable Sunday,
Otto

FWH/source/
classes
function
winapi



Yes, of course
But Prof. Mr. Otto you Know how make it?

Re: Get...bitmap..action

Posted: Mon Nov 29, 2021 3:07 pm
by karinha
See this example if it helps. It's not half full, and you can change the will when the example is complete, understand?

Code: Select all | Expand


// \SAMPLES\SILMAIL.PRG - 29/11/2021 - kapiabafwh@gmail.com.

#Include "FiveWin.ch"

STATIC oBtn, lBtnSshow := .T.

FUNCTION Btn_Mail()

   LOCAL oDlg, oGet, oFont, oBold, oSkinB, oBtnBmp
   LOCAL aGet   := ARRAY(5)
   LOCAL cEmail := SPACE(50), n2 := 1

   SetBalloon( .T. ) // Balloon shape required for tooltips

   oSkinB = TSkinButton():New()
   oSkinB:nClrBorder0_N := RGB( 249, 194, 179 )
   oSkinB:nClrBorder1_N := RGB( 181, 61, 29 )
   oSkinB:aClrNormal    := { { 0.2, RGB( 000, 128, 000 ), RGB( 000, 128, 000 ) }, ;
                             { 0.8, RGB( 109, 135, 100 ), RGB( 109, 135, 100 ) } }

   SkinButtons( oSkinB )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 14
   DEFINE FONT oBold NAME "TAHOMA" SIZE 0, - 14 BOLD

   DEFINE DIALOG oDlg SIZE 400, 300 PIXEL TRUEPIXEL                        ;
      COLOR CLR_BLACK,  nRgb( 245, 244, 234 )  FONT oFont                  ;
      TITLE "Silvio: Image Btn in GET from code of Silvio."

   oDlg:lHelpIcon := .F.

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
   ENDIF

   @ 10, 12 GET aGet[1] VAR cEmail PICTURE "@K" OF oDlg SIZE 300, 24 PIXEL ;
      UPDATE FONT oFont COLORS CLR_BLACK, CLR_WHITE WHEN( lBtnSshow )      ;
      BITMAP "..\bitmaps\Clock.bmp"                                        ;
      VALID( Cambia_Btn( aGet, cEmail ) )                                  ;
      ACTION( Cambia_Btn( aGet, cEmail ) )                                 ;
      ON CHANGE( IIF( .NOT. EMPTY( cEmail ),                               ;
         aGet[1]:oBtn:SetFile( "..\bitmaps\plus.bmp"),                     ;
         aGet[1]:oBtn:SetFile( "..\bitmaps\minus.bmp" ) ) )

   aGet[1]:cToolTip := OemToAnsi( "<F7> - Action for Silvio" )

   aGet[1]:lBtnTransparent := .T.
   aGet[1]:lAdjustBtn      := .T.       // Button Get Adjust Witdh aGet[1]
   aGet[1]:lDisColors      := .F.       // Deactive disable color
   aGet[1]:nClrTextDis     := CLR_WHITE // Color text disable status
   aGet[1]:nClrPaneDis     := CLR_CYAN  // Color Pane disable status

   // <F7> Action for Silvio. => one day he will learn.
   aGet[1]:bKeyDown := { |nKey| IF( nKey == VK_F7, Eval( aGet[1]:bAction ), Nil ) }

   @ 44.5, 12 GET aGet[2] VAR n2 OF oDlg SIZE 80, 24 PIXEL                 ;
      VALID( TURNS_GET1( aGet, cEmail ) ) UPDATE

   aGet[2]:cToolTip := "Turn on GET 1 Silvio. You get Silvio, believe me."

   @ 200, 160 BUTTONBMP oBtnBmp OF oDlg SIZE 80, 80 PIXEL                  ;
      BITMAP "..\bitmaps\AlphaBmp\ichat.bmp"                               ;
      ACTION( oDlg:End() ) CANCEL

   oBtnBmp:cToolTip := "Chat or Exit Silvio. one day he will learn."

   ACTIVATE DIALOG oDLg CENTERED

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
   ENDIF

   oFont:End()
   oBold:End()

RETURN NIL

FUNCTION Cambia_Btn( aGet, cEmail )

   IF EMPTY( cEMail )

      lBtnSshow := .F.

      aGet[1]:oBtn:SetFile( "..\bitmaps\minus.bmp" )

      aGet[1]:Refresh()

   ELSE

      lBtnSshow := .T.

      aGet[1]:oBtn:SetFile("..\bitmaps\plus.bmp")

      aGet[1]:Refresh()

   ENDIF

RETURN( .T. )

FUNCTION TURNS_GET1( aGet, cEmail )

   IF GETASYNCKEY( VK_UP )

      lBtnSshow := .T.

      aGet[1]:oBtn:SetFile( "..\bitmaps\Clock.bmp" )
      aGet[1]:Refresh()

   ENDIF

   IF GETASYNCKEY( VK_DOWN )

      lBtnSshow := .T.

      aGet[1]:oBtn:SetFile( "..\bitmaps\Exit.bmp" )
      aGet[1]:Refresh()

   ENDIF

RETURN( .T. )

// FIN / END
 

Re: Get...bitmap..action

Posted: Mon Nov 29, 2021 3:27 pm
by Otto
Hello Silvio,
I only mentioned this because Jimmy comes from a different "dBase" corner, where it is absolutely not customary to have access to the language's source code.
It is the generosity of Antonio who provided the source code of FIVEWIN to all of us.

Best regards,
Otto

Re: Get...bitmap..action

Posted: Mon Nov 29, 2021 5:35 pm
by Silvio.Falconi
for my advise
this question must be inserted on the class
show bitmap action only when tget is no empty

Re: Get...bitmap..action

Posted: Mon Nov 29, 2021 5:39 pm
by Silvio.Falconi
karinha wrote:See this example if it helps. It's not half full, and you can change the will when the example is complete, understand?

Code: Select all | Expand


// \SAMPLES\SILMAIL.PRG - 29/11/2021 - kapiabafwh@gmail.com.

#Include "FiveWin.ch"

STATIC oBtn, lBtnSshow := .T.

FUNCTION Btn_Mail()

   LOCAL oDlg, oGet, oFont, oBold, oSkinB, oBtnBmp
   LOCAL aGet   := ARRAY(5)
   LOCAL cEmail := SPACE(50), n2 := 1

   SetBalloon( .T. ) // Balloon shape required for tooltips

   oSkinB = TSkinButton():New()
   oSkinB:nClrBorder0_N := RGB( 249, 194, 179 )
   oSkinB:nClrBorder1_N := RGB( 181, 61, 29 )
   oSkinB:aClrNormal    := { { 0.2, RGB( 000, 128, 000 ), RGB( 000, 128, 000 ) }, ;
                             { 0.8, RGB( 109, 135, 100 ), RGB( 109, 135, 100 ) } }

   SkinButtons( oSkinB )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 14
   DEFINE FONT oBold NAME "TAHOMA" SIZE 0, - 14 BOLD

   DEFINE DIALOG oDlg SIZE 400, 300 PIXEL TRUEPIXEL                        ;
      COLOR CLR_BLACK,  nRgb( 245, 244, 234 )  FONT oFont                  ;
      TITLE "Silvio: Image Btn in GET from code of Silvio."

   oDlg:lHelpIcon := .F.

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
   ENDIF

   @ 10, 12 GET aGet[1] VAR cEmail PICTURE "@K" OF oDlg SIZE 300, 24 PIXEL ;
      UPDATE FONT oFont COLORS CLR_BLACK, CLR_WHITE WHEN( lBtnSshow )      ;
      BITMAP "..\bitmaps\Clock.bmp"                                        ;
      VALID( Cambia_Btn( aGet, cEmail ) )                                  ;
      ACTION( Cambia_Btn( aGet, cEmail ) )                                 ;
      ON CHANGE( IIF( .NOT. EMPTY( cEmail ),                               ;
         aGet[1]:oBtn:SetFile( "..\bitmaps\plus.bmp"),                     ;
         aGet[1]:oBtn:SetFile( "..\bitmaps\minus.bmp" ) ) )

   aGet[1]:cToolTip := OemToAnsi( "<F7> - Action for Silvio" )

   aGet[1]:lBtnTransparent := .T.
   aGet[1]:lAdjustBtn      := .T.       // Button Get Adjust Witdh aGet[1]
   aGet[1]:lDisColors      := .F.       // Deactive disable color
   aGet[1]:nClrTextDis     := CLR_WHITE // Color text disable status
   aGet[1]:nClrPaneDis     := CLR_CYAN  // Color Pane disable status

   // <F7> Action for Silvio. => one day he will learn.
   aGet[1]:bKeyDown := { |nKey| IF( nKey == VK_F7, Eval( aGet[1]:bAction ), Nil ) }

   @ 44.5, 12 GET aGet[2] VAR n2 OF oDlg SIZE 80, 24 PIXEL                 ;
      VALID( TURNS_GET1( aGet, cEmail ) ) UPDATE

   aGet[2]:cToolTip := "Turn on GET 1 Silvio. You get Silvio, believe me."

   @ 200, 160 BUTTONBMP oBtnBmp OF oDlg SIZE 80, 80 PIXEL                  ;
      BITMAP "..\bitmaps\AlphaBmp\ichat.bmp"                               ;
      ACTION( oDlg:End() ) CANCEL

   oBtnBmp:cToolTip := "Chat or Exit Silvio. one day he will learn."

   ACTIVATE DIALOG oDLg CENTERED

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
   ENDIF

   oFont:End()
   oBold:End()

RETURN NIL

FUNCTION Cambia_Btn( aGet, cEmail )

   IF EMPTY( cEMail )

      lBtnSshow := .F.

      aGet[1]:oBtn:SetFile( "..\bitmaps\minus.bmp" )

      aGet[1]:Refresh()

   ELSE

      lBtnSshow := .T.

      aGet[1]:oBtn:SetFile("..\bitmaps\plus.bmp")

      aGet[1]:Refresh()

   ENDIF

RETURN( .T. )

FUNCTION TURNS_GET1( aGet, cEmail )

   IF GETASYNCKEY( VK_UP )

      lBtnSshow := .T.

      aGet[1]:oBtn:SetFile( "..\bitmaps\Clock.bmp" )
      aGet[1]:Refresh()

   ENDIF

   IF GETASYNCKEY( VK_DOWN )

      lBtnSshow := .T.

      aGet[1]:oBtn:SetFile( "..\bitmaps\Exit.bmp" )
      aGet[1]:Refresh()

   ENDIF

RETURN( .T. )

// FIN / END
 



I cannot make this
I have many gets on a dialog with bitmap action, how many sources i must insert?
my advice the show bitmap action only when the get is no empty must be inserted on the tget class

your script run only when tget create btnbmp but if the button is not transparent tget create a buttobmp control, then setfile function is not good