Strange SET DIALOGBOX POSITION behaviour
Moderator: Rathinagiri
-
- Posts: 682
- Joined: Tue Jun 04, 2013 6:33 pm
- Location: Argentina
Re: Strange SET DIALOGBOX POSITION behaviour
Hi Friends:
Mol said: "In this case, you need to create your own inputbox function". I agree with Mol.-
I think is the best solution, not only to obtain the functionality you need; Mol's solutions goes behind: dialog boxes depends of the skin of your OS; if you define your own dialog boxes, they'll look the same no mather what OS (XP, 7, 8, 10) end users haves.- It's not difficult, you need a good image, create a modal window, and introduce at least 5 controls. Nothing else.-
Just an opinion.-
With regards.-
Eduardo
Mol said: "In this case, you need to create your own inputbox function". I agree with Mol.-
I think is the best solution, not only to obtain the functionality you need; Mol's solutions goes behind: dialog boxes depends of the skin of your OS; if you define your own dialog boxes, they'll look the same no mather what OS (XP, 7, 8, 10) end users haves.- It's not difficult, you need a good image, create a modal window, and introduce at least 5 controls. Nothing else.-
Just an opinion.-
With regards.-
Eduardo
Re: Strange SET DIALOGBOX POSITION behaviour
Hi Eduardo,
Thanks for your opinion but with all respect this is not about the InputBox() function anymore. I followed Mol his advice and created my own. I posted the result earlier in this post. Also Claudio is right. InputWindow and InputBox not are dialog Boxes but normal windows they do not have to obey 'SET DIALOGBOX POSITION CENTER OF' but the modified h_controlmisc it does.
InputBox() problem solved, InputBox() case closed.
But with the help of Andrés i narrowed down the 'SET DIALOGBOX POSITION CENTER OF' problem to the MessageBoxTimeout() function. This function does NOT always respect 'SET DIALOGBOX POSITION CENTER OF' when using the menu. The MessageBoxTimeout() is a dialog box and should obey the 'SET DIALOGBOX POSITION CENTER OF'. You can see for yourselves when you compile the demo in the first post.
Both MessageBoxTimeout() and 'SET DIALOGBOX POSITION CENTER OF' are created by Claudio and in combination with the MENU function they contain a bug. The older (and less flexible) functions like MsgYesNo(), MsgStop() and MsgRetryCancel() DO respect 'SET DIALOGBOX POSITION CENTER OF' and do not contain the bug. So until someone fixes the MessageBoxTimeout() bug with 'SET DIALOGBOX POSITION CENTER OF' i have got a workaround.
Theo
Thanks for your opinion but with all respect this is not about the InputBox() function anymore. I followed Mol his advice and created my own. I posted the result earlier in this post. Also Claudio is right. InputWindow and InputBox not are dialog Boxes but normal windows they do not have to obey 'SET DIALOGBOX POSITION CENTER OF' but the modified h_controlmisc it does.
InputBox() problem solved, InputBox() case closed.
But with the help of Andrés i narrowed down the 'SET DIALOGBOX POSITION CENTER OF' problem to the MessageBoxTimeout() function. This function does NOT always respect 'SET DIALOGBOX POSITION CENTER OF' when using the menu. The MessageBoxTimeout() is a dialog box and should obey the 'SET DIALOGBOX POSITION CENTER OF'. You can see for yourselves when you compile the demo in the first post.
Both MessageBoxTimeout() and 'SET DIALOGBOX POSITION CENTER OF' are created by Claudio and in combination with the MENU function they contain a bug. The older (and less flexible) functions like MsgYesNo(), MsgStop() and MsgRetryCancel() DO respect 'SET DIALOGBOX POSITION CENTER OF' and do not contain the bug. So until someone fixes the MessageBoxTimeout() bug with 'SET DIALOGBOX POSITION CENTER OF' i have got a workaround.
Theo
-
- Posts: 682
- Joined: Tue Jun 04, 2013 6:33 pm
- Location: Argentina
Re: Strange SET DIALOGBOX POSITION behaviour
Hi Trmpluym:
Please forgive me; when i post my suggestion, unfortunatly i said "inputbox", but i referred to both inputbox and msgboxes.-
In my example (see folder SAMPLES\APPLICATIONS\MINIWRITER of your HMG) you'll find what i try to explain.- I don't use any MSGBOX; i create my own msgbox using different modal windows that i put on any position of the screen; in some cases i put it on a corner, on other centered on the monitor screen or centered on another modal window.- Please take a look of Miniwriter code.- I hope this may help you; if not, take this message as a colaboration.-
With regards.
Eduardo
Please forgive me; when i post my suggestion, unfortunatly i said "inputbox", but i referred to both inputbox and msgboxes.-
In my example (see folder SAMPLES\APPLICATIONS\MINIWRITER of your HMG) you'll find what i try to explain.- I don't use any MSGBOX; i create my own msgbox using different modal windows that i put on any position of the screen; in some cases i put it on a corner, on other centered on the monitor screen or centered on another modal window.- Please take a look of Miniwriter code.- I hope this may help you; if not, take this message as a colaboration.-
With regards.
Eduardo
Re: Strange SET DIALOGBOX POSITION behaviour
Hi Eduardo,
Your miniwriter work is very impressive, my compliments ! And yes i can also create my own msgbox. But the MessageBoxTimeout() does exactly what i need and is flexible. The only problem is the bug i described. Because of the bug MessageBoxTimeout() just do not do what it supposed to do. Hopefully this bug is fixed in the near future.
Personally my opinion is it is better to evolve the standard functions and make them better every HMG release instead of everybody creating their own functions.
But for the record. I very much appreciate your comment and i am thankful you took the time trying to help me out ! I didn't mean to offend you..
Theo
Your miniwriter work is very impressive, my compliments ! And yes i can also create my own msgbox. But the MessageBoxTimeout() does exactly what i need and is flexible. The only problem is the bug i described. Because of the bug MessageBoxTimeout() just do not do what it supposed to do. Hopefully this bug is fixed in the near future.
Personally my opinion is it is better to evolve the standard functions and make them better every HMG release instead of everybody creating their own functions.
But for the record. I very much appreciate your comment and i am thankful you took the time trying to help me out ! I didn't mean to offend you..
Theo
Re: Strange SET DIALOGBOX POSITION behaviour
Dear HMG friends,
I want to share a fix i created for the 'SET DIALOGBOX POSITION' bug
In the main program i create an event _HMG_FixDialogBoxProcedure by adding the line:
And here is the FIX code:
In the attachement the demo with the fix included. The MessageBoxTimeout function now behaves like it should !
I hope other HMG members can use it !
I want to share a fix i created for the 'SET DIALOGBOX POSITION' bug
In the main program i create an event _HMG_FixDialogBoxProcedure by adding the line:
Code: Select all
CREATE EVENT PROCNAME _HMG_FixDialogBoxProcedure()
Code: Select all
FUNCTION _HMG_FixDialogBoxProcedure()
LOCAL hWnd := GetActiveWindow(), hWndParent, nCol, nRow
IF GetClassName ( hWnd ) == "#32770" // The class name for a dialog box is --> #32770
#define SWP_NOOWNERZORDER 0x0200
#define SWP_NOSIZE 0x0001
hWndParent := GetParent(hWnd)
nCol := GetWindowCol(hWndParent) + ( GetWindowWidth(hWndParent) - GetWindowWidth(hWnd) ) / 2
nRow := GetWindowRow(hWndParent) + ( GetWindowHeight(hWndParent) - GetWindowHeight(hWnd) ) / 2
SetWindowPos ( hWnd, 0, nCol, nRow, 0, 0, SWP_NOOWNERZORDER + SWP_NOSIZE)
ENDIF
RETURN NIL
I hope other HMG members can use it !
- Attachments
-
- 2016-10-15 17_58_50-Test.jpg (17.44 KiB) Viewed 4639 times
Last edited by trmpluym on Sat Oct 15, 2016 4:22 pm, edited 1 time in total.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Strange SET DIALOGBOX POSITION behaviour
Nice Theo,
It's some kind of radical measure for DialogBox. But at least you the good result.
I do not know if we could apply in HMG library with similar solution...
Thank you for sharing.
It's some kind of radical measure for DialogBox. But at least you the good result.
I do not know if we could apply in HMG library with similar solution...
Thank you for sharing.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: Strange SET DIALOGBOX POSITION behaviour
I understand, it is more a quick fix for now. Claudio probably will find the real solution but he has got a lot of work to do and i do not want to rush him.Pablo César wrote:Nice Theo,
It's some kind of radical measure for DialogBox. But at least you the good result.
I do not know if we could apply in HMG library with similar solution...
For now i can repair my problems with this fix so the MessageBoxTimeout function behaves properly !
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Strange SET DIALOGBOX POSITION behaviour
Dank u, een goede kereltrmpluym wrote:Claudio probably will find the real solution but he has got a lot of work to do and i do not want to rush him.
For now i can repair my problems with this
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: Strange SET DIALOGBOX POSITION behaviour
Muito Obrigado
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Center POSITION to Parent Window
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: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?
This idea is great but there is an objection. cParentWindowName assigning can It may fail when Window Parent does not exist.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 ...
... and 3876 to 3878Code: Select all
Local cParentWindowName:=ThisWindow.Name
Code: Select all
If nRow < 0 .or. nCol < 0 CENTER WINDOW _InputWindow IN &cParentWindowName EndIf
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
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,"")
Code: Select all
If _HMG_MainWindowFirst==.T.
CENTER WINDOW _InputBox IN &cParentWindowName
Else
CENTER WINDOW _InputBox DESKTOP
Endif
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein