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: 149 times
Contact:

Re: Center POSITION to Parent Window

Post by srvet_claudio »

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 »

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: 258
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 8 times
Been thanked: 27 times

Post by trmpluym »

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 »

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: 2414
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 727 times
Been thanked: 133 times
Contact:

Post by serge_girard »

Thanks Pablo and Theo !

Serge

trmpluym
Posts: 258
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 8 times
Been thanked: 27 times

Post by trmpluym »

Hi friends,

I never got a reply with the solution for this problem. But finally I found the solution my selves !

And like often, a good solution is simple. Here the code with the strange behavior:

Code: Select all

IF MessageBoxTimeout('Quit program ?','Quit?',MB_ICONQUESTION + MB_YESNO) == IDYES
   Return(.T.)
ENDIF
This code seems not to respect:

SET DIALOGBOX POSITION CENTER OF <Parent>

And here the code that does:

Code: Select all

IF MessageBoxTimeout('Quit program ?','Quit?',MB_ICONQUESTION + MB_YESNO + MB_TOPMOST) == IDYES
   Return(.T.)
ENDIF
So the only required change was to add ‘ + MB_TOPMOST ‘
So hopefully this saves anybody else some time (and frustration :D )

Theo
Attachments
Solution.zip
(1.47 MiB) Downloaded 34 times

Post Reply