Page 1 of 1

change "Caption" and "ACTION" Codeblock of a Button ?

Posted: Tue Dec 31, 2019 12:00 am
by AUGE_OHR
hi,

how can i change "Caption" and "ACTION" Codeblock of a Button in a FMG after Create :?:

Code: Select all

    DEFINE BUTTON Button_2
        ROW    550
        COL    20
        WIDTH  58
        HEIGHT 28
        ACTION ShowDir("INI")
        CAPTION "Click.INI"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON
i have try

Code: Select all

   SetProperty( "ClickForm", "Button_2","Caption","hello" )
   SetProperty( "ClickForm", "Button_2","Action",MsgInfo("world") )
"Caption" was easy but "Action" does not work ... still old Codeblock :(

in c:\hmg.3.4.4\SOURCE\h_button.prg i say

Code: Select all

Function _DefineButton ( ControlName, ParentForm, x, y, Caption, ProcedureName, ;

   _HMG_SYSDATA [  6 ] [k] := ProcedureName 
so how can i use that :?:

---

in hb_Debugger i found some Code to show Method/Var but it need a Object

Code: Select all

   oObj := SetProperty( "ClickForm", "Button_2")
it give me NIL not Object :cry:

who can help please

Re: change "Caption" and "ACTION" Codeblock of a Button ?

Posted: Tue Dec 31, 2019 4:08 am
by AUGE_OHR
hi,

have found a Way

Code: Select all

PROCEDURE ShowAction( cWho )
LOCAL nIndex     := GetControlIndex( "Button_StartClick", "ClickForm" )

   DO CASE
      CASE cWho = "ESC"
         SetProperty( "ClickForm", "Button_StartClick", "Caption", "Abort" )
         _HMG_SYSDATA[ 6 ] [ nIndex ] := { || DoEsc() }

      CASE cWho = "EXIT"
         SetProperty( "ClickForm", "Button_StartClick", "Caption", "Exit" )
         _HMG_SYSDATA[ 6 ] [ nIndex ] := { || DoExit() }

      CASE cWho = "CLICK"
         SetProperty( "ClickForm", "Button_StartClick", "Caption", "Click" )
         _HMG_SYSDATA[ 6 ] [ nIndex ] := { || StartClick() }
   ENDCASE

RETURN
it must be a Codeblock :!:

as you see i use same "Button_StartClick" with different Caption and Codeblock and can change it "on-fly"

p.s. have not test it with Image ...