Strange SET DIALOGBOX POSITION behaviour

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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:

Re: Center POSITION to Parent Window

Post by srvet_claudio » Thu Dec 15, 2016 12:33 am

Pablo César wrote:
trmpluym wrote:Also the following functions ...

InputWindow
InputBox

The last one is always centered, the first you can change the row and the column.

...

nRow and nCol are optional. When nRow or nCol are 0 the InputWindow is positioned in the center of the screen.

With the modification i made the functionality stays the same but when nRow of nCol is a negative number (<0) the InputWindow is positioned in the center of the parent form.

Maybe an idea to include in the next release?
I think the InputBox and InputWindow functions should always be based on the Parent Window because it is the window that called it and if the programmer has defined a specific Form position (non Window Parent centralized) the InputBox and InputWindow should consider the centering as the base/default window (Parent Window). You can still change the row and column as optional parameters as already exists.
trmpluym wrote:I changed the source file c:\hmg.3.4.3\SOURCE\h_controlmisc.prg with only four lines to add the possibility to center the InputWindow in the parent window.

The lines i added are line 3099 ...

Code: Select all

Local cParentWindowName:=ThisWindow.Name
... and 3876 to 3878

Code: Select all

If nRow < 0 .or. nCol < 0                                     
   CENTER WINDOW _InputWindow IN &cParentWindowName           
EndIf 
This idea is great but there is an objection. cParentWindowName assigning can It may fail when Window Parent does not exist.
Remembering that the user has the possibility to use:

Code: Select all

Function Main()
SET WINDOW MAIN OFF
MsgInfo ( InputBox ( 'Renovación del condominio anual para todos los asociados y con accion de la justicia para los que deben:' , 'InputBox Demo' , 'Default Value' , , , ,700 ) )
SET WINDOW MAIN ON
Return Nil
SET WINDOW MAIN OFF I use a lot. Especially when I need to do some tests.

So, to attend also that cases at Local cParentWindowName:=ThisWindow.Name, we can make this instead:

Code: Select all

Local cParentWindowName:=If(_HMG_MainWindowFirst==.T.,ThisWindow.Name,"")
and to center the window:

Code: Select all

If _HMG_MainWindowFirst==.T.
   CENTER WINDOW _InputBox IN &cParentWindowName
Else
   CENTER WINDOW _InputBox DESKTOP
Endif
What do you thing Claudio ? We can centralized InputBox and InputWindow in Parent Window instead negatives value ? And make respective conditional for preventing case of SET WINDOW MAIN OFF in both functions ?
I will think about it !
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Thu Dec 15, 2016 9:19 am

Ok, thank you Claudio.

Just FYG, in this topic (same topic): you said "nice" (as probably in agree with that) and
with certainty: not predicting _HMG_MainWindowFirst==.F. which will certainly occur a runtime error.

The change, centralization still maintains the option to position the _Input_Window where the user wants,
through the additional parameters of row / col.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

trmpluym
Posts: 242
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 6 times
Been thanked: 21 times

Post by trmpluym » Sun Dec 18, 2016 9:45 pm

Pablo César wrote:
trmpluym wrote:Also the following functions ...

So, to attend also that cases at Local cParentWindowName:=ThisWindow.Name, we can make this instead:

Code: Select all

Local cParentWindowName:=If(_HMG_MainWindowFirst==.T.,ThisWindow.Name,"")
and to center the window:

Code: Select all

If _HMG_MainWindowFirst==.T.
   CENTER WINDOW _InputBox IN &cParentWindowName
Else
   CENTER WINDOW _InputBox DESKTOP
Endif
What do you thing Claudio ? We can centralized InputBox and InputWindow in Parent Window instead negatives value ? And make respective conditional for preventing case of SET WINDOW MAIN OFF in both functions ?
Thank you for improving my version Pablo ! Hopefully it will be included in the next HMG release !

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Sun Dec 18, 2016 9:53 pm

It's a pleasure Theo. I hope so too... :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

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

Post by serge_girard » Mon Dec 19, 2016 9:31 am

Thanks Pablo and Theo !

Serge

Post Reply