OptionBox()

Source code related resources

Moderator: Rathinagiri

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

OptionBox()

Post by Roberto Lopez » Tue Jun 28, 2016 5:44 pm

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: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Tue Jun 28, 2016 6:22 pm

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: 385
Joined: Sat Dec 12, 2009 3:40 pm
Has thanked: 1 time
Been thanked: 2 times

Post by Steed » Tue Jun 28, 2016 8:39 pm

Thks

User avatar
danielmaximiliano
Posts: 2136
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 154 times
Been thanked: 23 times
Contact:

Post by danielmaximiliano » Tue Jun 28, 2016 10:31 pm

Gracias Roberto por compartir.....

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

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
andyglezl
Posts: 1151
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 35 times
Been thanked: 68 times
Contact:

Post by andyglezl » Wed Jun 29, 2016 1:02 am

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

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Wed Jun 29, 2016 1:25 am

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

User avatar
bpd2000
Posts: 1077
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 197 times
Been thanked: 96 times

Post by bpd2000 » Wed Jun 29, 2016 4:29 am

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

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

Post by serge_girard » Wed Jun 29, 2016 7:32 am

Very handy !
To be included in next vesion?

Serge

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

Post by esgici » Wed Jun 29, 2016 8:45 am

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

Serge
+1
Viva INTERNATIONAL HMG :D

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

Post by chrisjx2002 » Wed Jun 29, 2016 8:51 am

+1

Post Reply