Page 3 of 4
Re: OptionBox()
Posted: Fri Jul 01, 2016 2:24 pm
by tonton2
Merci beaucoup Roberto
OptionBox()
Posted: Wed Jan 18, 2017 10:56 pm
by Pablo César
Roberto Lopez wrote: ↑Fri Jul 01, 2016 12:19 pm
tonton2 wrote:Hello to all the team,
how to use this program with IDE
Thank you for your help
This is a simple function. You could add it to your own code (using the IDE or not).
Thank you big boss Roberto for nice and simple solution.
I've already started using it but with some changes.
Attached is my contribution with following improving:
- Fixed overwriting control display in RadioGroup items on frame
- Added multilanguage support in buttons
- Autoadjustable width sizes (form, and RadioGroup) by size of items and size o Title and buttons centralized
- Optional title in frame. Useful when form title is too long.
- FontSize definition for whole controls
And along with a practical example:
- MsgBox.rar
- Source files
- (1.56 KiB) Downloaded 251 times
I hope you enjoy
I know that we still need to improve the ItemsMaxLen function for the FontHandle could work correctly, especially if the FontSize changes.
I could not get FontHandle because at this stage there is no control nor form created yet. I think that for you want to work with source change you must enable the line:
Code: Select all
AEVAL( aItems, { | cItem | nMxLn := Max( nMxLn, HMG_Len( cItem ) * nFontSize * .8 ) } )
This line-example is a contribution of the colleague Esgici that I borrowed.

- Screen52.png (11.25 KiB) Viewed 4987 times
This is with FontSize 12 (exaggerated but automatic adjustment working, just for fun).

Re: OptionBox()
Posted: Thu Jan 19, 2017 8:25 am
by serge_girard
Thanks Pablo and Roberto!
Serge
Re: OptionBox()
Posted: Sat Jan 21, 2017 6:12 pm
by trmpluym
Hi Roberto,
Thanks for this great new function ! Very useful !
Here some minor improvements based on the last modified version of Pablo:
(1) Centre in parent Window when a parent window is defined
Code: Select all
IF ASCAN( _HMG_SYSDATA[69], "A" ) > 0 .AND. _HMG_MainWindowFirst==.T.
cParentWindowName:=ThisWindow.Name
CENTER WINDOW OPTIONBOX IN &cParentWindowName
ELSE
CENTER WINDOW OPTIONBOX DESKTOP
ENDIF
ASCAN( _HMG_SYSDATA[69], "A" ) > 0 if a MAIN window is defined
_HMG_MainWindowFirst==.F. when SET WINDOW MAIN OFF (like Pablo uses often)
(2) nRet variable changed from PRIVATE to LOCAL
Code: Select all
DEFINE BUTTON CANCEL
ROW 110 + ( 30 * ( LEN(aOptions) - 2 ) )
COL nColButtons + 110
CAPTION cCaption2
ACTION OptionBox_Cancel(@nRet)
FONTNAME "Arial"
FONTSIZE nFontSize
END BUTTON
ON KEY ESCAPE ACTION OptionBox_Cancel(@nRet)
And
Code: Select all
Function OptionBox_Cancel(nRet)
ThisWindow.RELEASE
SET WINDOW MAIN ON
Return Nil
Without the PRIVATE variable i can use the nRet variable 'safely' in other code.
OptionBox()
Posted: Sat Jan 21, 2017 6:20 pm
by Pablo César
Dank u Theo !
Ik vergat je aangegeven centralisatie.
I am adopting your changes, thanks again
Re: OptionBox()
Posted: Sat Jan 21, 2017 6:32 pm
by trmpluym
Você é meu amigo Pablo!
+1
OptionBox()
Posted: Mon Jan 23, 2017 1:14 pm
by Pablo César
trmpluym wrote: ↑Sat Jan 21, 2017 6:32 pm
Você é meu amigo Pablo!
+1
Thank Theo, you are as my friend too !
I think we can add an optional parameter giving chance to include personalized ICON at this window of OptionBox()
But do not forget to:
- Remove NOSYSMENU at DEFINE WINDOW OPTIONBOX
- Change LOCAL cParentWindowName, nRet for LOCAL cParentWindowName, nRet: = 0 based on Theo example
- Add the 5th parameter and variable for ICON name
- Add ON RELEASE (nRet := 0) to the end of DEFINE WINDOW OPTIONBOX
- Changed MODAL by TOPMOST
- To fix Cancel option at line after Function OptionBox_Cancel(nRet) add nRet := 0.
Otherwise always will wrong return the value of RadioGroup (never as zero) 
To insure us about the changes, please review the attached example:
<Attached file was removed due there is a newest version ahead this topic (fixed bug)>

- Screen2.png (12.81 KiB) Viewed 4840 times
I hope you like it.

OptionBox()
Posted: Mon Jan 23, 2017 5:26 pm
by Pablo César
There was two bugs due removing NOSYSMENU and missing pass variable as reference (@).
Button "x" for exit form interferes when be cRet equal to zero or when is valid radioGroup value.
So, I have disabled this button with:
SetProperty("OPTIONBOX","NOCLOSE",.T.)
And also was fixed/added
OptionBox_Ok(@nRet) due cRet now is not PRIVATE as Theo has recommended.
Here's fixed version:
- MsgBox.rar
- Executable and source files
- (1.24 MiB) Downloaded 278 times
Sorry for my mistake.
Re: OptionBox()
Posted: Mon Jan 23, 2017 5:32 pm
by trmpluym
Perfect Pablo, the function improves everytime
Theo
OptionBox()
Posted: Mon Jan 23, 2017 5:40 pm
by Pablo César
Bedankt Theo!