OptionBox()

Source code related resources

Moderator: Rathinagiri

User avatar
tonton2
Posts: 444
Joined: Sat Jun 29, 2013 1:26 pm
Location: Algerie
Contact:

Re: OptionBox()

Post by tonton2 »

Merci beaucoup Roberto
L'Algerie vous salut
Y.TABET
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

OptionBox()

Post 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 219 times
 
I hope you enjoy :P

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
Screen52.png (11.25 KiB) Viewed 4386 times
 
This is with FontSize 12 (exaggerated but automatic adjustment working, just for fun). :P
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: OptionBox()

Post by serge_girard »

Thanks Pablo and Roberto!
Serge
There's nothing you can do that can't be done...
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: OptionBox()

Post 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.
Attachments
msgbox.zip
(1.5 MiB) Downloaded 241 times
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

OptionBox()

Post by Pablo César »

Dank u Theo !

Ik vergat je aangegeven centralisatie.

I am adopting your changes, thanks again
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: OptionBox()

Post by trmpluym »

Você é meu amigo Pablo!

+1
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

OptionBox()

Post 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:
  1. Remove NOSYSMENU at DEFINE WINDOW OPTIONBOX
  2. Change LOCAL cParentWindowName, nRet for LOCAL cParentWindowName, nRet: = 0 based on Theo example
  3. Add the 5th parameter and variable for ICON name
  4. Add ON RELEASE (nRet := 0) to the end of DEFINE WINDOW OPTIONBOX
  5. Changed MODAL by TOPMOST
  6. 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
Screen2.png (12.81 KiB) Viewed 4239 times
 
I hope you like it. :)
Last edited by Pablo César on Mon Jan 23, 2017 5:27 pm, edited 2 times in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

OptionBox()

Post 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 243 times
 
Sorry for my mistake.
Last edited by Pablo César on Mon Jan 23, 2017 5:32 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: OptionBox()

Post by trmpluym »

Perfect Pablo, the function improves everytime :D

Theo
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

OptionBox()

Post by Pablo César »

Bedankt Theo!
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply