OptionBox()

Source code related resources

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 3987
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 27 times
Been thanked: 172 times

OptionBox()

Post by Roberto Lopez »

Hi All,

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

I'm not fully sure, but I guess I've not posted here yet.

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

Code: Select all

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
I hope it be useful for someone.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
Rathinagiri
Posts: 5313
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 194 times
Been thanked: 208 times
Contact:

Post by Rathinagiri »

Really simple and nice one Roberto.

Kindly accept my small modification to include the escape key functionality.

Code: Select all

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
      ON KEY ESCAPE ACTION OPTIONBOX_CANCEL()

   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
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Steed
Posts: 406
Joined: Sat Dec 12, 2009 3:40 pm
Has thanked: 2 times
Been thanked: 2 times

Post by Steed »

Thks

User avatar
danielmaximiliano
Posts: 2321
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 378 times
Been thanked: 74 times
Contact:

Post by danielmaximiliano »

Gracias Roberto por compartir.....

siempre viene bien pequeñas cositas que agrandan y mejoran la APP
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
andyglezl
Posts: 1251
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 39 times
Been thanked: 107 times
Contact:

Post by andyglezl »

Gracias !
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
srvet_claudio
Posts: 2073
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 46 times
Been thanked: 187 times
Contact:

Post by srvet_claudio »

Very nice!
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
bpd2000
Posts: 1161
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 248 times
Been thanked: 144 times

Post by bpd2000 »

srvet_claudio wrote:Very nice!
+1
BPD
Convert Dream into Reality through HMG

User avatar
serge_girard
Posts: 2521
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 825 times
Been thanked: 154 times
Contact:

Post by serge_girard »

Very handy !
To be included in next vesion?

Serge

User avatar
esgici
Posts: 4532
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 407 times
Been thanked: 116 times
Contact:

Post by esgici »

serge_girard wrote:Very handy !
To be included in next vesion?

Serge
+1
Viva INTERNATIONAL HMG :D

chrisjx2002
Posts: 173
Joined: Wed Jan 06, 2010 5:39 pm
Been thanked: 2 times

Post by chrisjx2002 »

+1

Post Reply