TUNING HMG: OptionBox()

Note: This function was already posted to HMG developers and it will be included in the next version (but it is not available on the current (at the time of this writing) 3.4.3)

Some years ago, I’ve created a tiny function for my own use.

This is called ‘OptionBox‘ and its name is self-explanatory :)

FUNCTION OPTIONBOX( cTitle , aOptions , nDefault )

PRIVATE nRet

   IF VALTYPE(nDefault) = 'U'
      nDefault := 1
   ENDIF

         DEFINE WINDOW OPTIONBOX ;
      AT 0,0 ;
      WIDTH 275 HEIGHT 170 + ( 30 * ( LEN(aOptions) - 2 ) );
      TITLE cTitle  ;
      MODAL NOSIZE NOSYSMENU

      DEFINE FRAME Frame_1
         ROW   04
         COL   10
         WIDTH   250
         HEIGHT   80 + ( 30 * ( LEN(aOptions) - 2 ) )
         CAPTION ''
      END FRAME

      DEFINE RADIOGROUP Radio_1
         ROW   20
         COL   30
         WIDTH   230 
         HEIGHT   100 + ( 30 * ( LEN(aOptions) - 2 ) )
         OPTIONS   aOptions
         VALUE   nDefault
         ONCHANGE {|| nRet := THIS.VALUE }
      END RADIOGROUP

      DEFINE BUTTON OK
         ROW   100 + ( 30 * ( LEN(aOptions) - 2 ) )
         COL   30
         CAPTION   'Aceptar'
         ACTION   OPTIONBOX_OK()
      END BUTTON

      DEFINE BUTTON CANCEL
         ROW   100 + ( 30 * ( LEN(aOptions) - 2 ) )
         COL   140
         CAPTION   'Cancelar'
         ACTION   OPTIONBOX_CANCEL()
      END BUTTON

   END WINDOW

   CENTER WINDOW OPTIONBOX
   ACTIVATE WINDOW OPTIONBOX


RETURN nRet

PROCEDURE OPTIONBOX_OK
   nRet := OPTIONBOX.RADIO_1.VALUE
   THISWINDOW.RELEASE
RETURN

PROCEDURE OPTIONBOX_CANCEL
   nRet := 0
   THISWINDOW.RELEASE
RETURN

Download the code (‘optionbox.7z’) from here

You can comment about this here (you need a SourceForge account to be able to post)

Enjoy!

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.