Page 4 of 4

Re: Center POSITION to Parent Window

Posted: Thu Dec 15, 2016 12:33 am
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 !

Strange SET DIALOGBOX POSITION behaviour

Posted: Thu Dec 15, 2016 9:19 am
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.

Re: Center POSITION to Parent Window

Posted: Sun Dec 18, 2016 9:45 pm
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 !

Strange SET DIALOGBOX POSITION behaviour

Posted: Sun Dec 18, 2016 9:53 pm
by Pablo César
It's a pleasure Theo. I hope so too... :)

Re: Strange SET DIALOGBOX POSITION behaviour

Posted: Mon Dec 19, 2016 9:31 am
by serge_girard
Thanks Pablo and Theo !

Serge

Re: Strange SET DIALOGBOX POSITION behaviour

Posted: Sat Dec 21, 2019 11:44 am
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