Page 2 of 3
Re: An alternative FontRequester [Windows only]
Posted: Thu Mar 13, 2025 11:05 am
by Zapman
ChrisR wrote: Wed Mar 12, 2025 5:58 pmOtherwise, I've never really understood how to define the position of FontRequester(), it's always vertically centered here.
If you're talking about the original FontRequester, it works well for me when I use the 'ParentID' parameter. It is positionned relatively to the top-left coordinates of the parent window, with a xShift arround 100px and an YShift arround 200px.
For FontRequesterEx, following your judicious remarks, I added the optional parameters XShift = 0, YShift = 0 and *UserChoice.Integer = 0, as well as a comment saying this:
; * If 'ParentWindow' contains a value, the FontRequester window will be centered relative to the parent window.
; Otherwise the window will be centered relatively to the last active window or to the main screen monitor
; if there is no opened windows.
;
; * If defined, 'XShift' and 'YShift' shift the origins or the FontRequesterEx window from its theoretical position.
;
; * If *UserChoice is a non-zero value, it will be considered as a pointer to an integer that will receive
; '1' if the user clicked on 'OK' and '0' if it clicked on 'Cancel'.
; If the user clicked on 'Cancel', the string returned by the procedure will be equal to the 'FontDescription$' entry parameter
The code of the first post has been updated.
Re: An alternative FontRequester [Windows only]
Posted: Fri Mar 14, 2025 12:06 am
by ChrisR
Thanks for the update zapman
Well, for the position of the window centered in relation to the active window or desktop,
I would have preferred not to have a parent window in parameters but to have the X and Y positions instead (default 0).
If 0 the window is centered and otherwise the position relative to the active window or desktop, clip to the edge of the screen.
But I'm not going to bother you with these little details, I'll do it for my needs.
Re: An alternative FontRequester [Windows only]
Posted: Fri Mar 14, 2025 7:06 am
by Zapman
Hi ChrisR,
With the actual version, Parent window can be set to #PB_Default, to not be taken in account. I can eventually add the possibility to set it to -2, to transform the xShift and yShift into absolue coordinates. By that way, all possibilities should be explored. Would it be good for you ?
Re: An alternative FontRequester [Windows only]
Posted: Fri Mar 14, 2025 12:52 pm
by ChrisR
Hi zapman,
Yes, I think it would look good like this. With -2, it would then be possible to position FontRequesterEx exactly where you want it, next to a button, at the bottom left of the window,...
However I've never really understood the point of defining a parent window, except creating a dummy window to bypass the default positioning.
GetActiveWindow() seems enough to me: If GetActiveWindow() And X <> #PB_Default : WindowX(GetActiveWindow(), #PB_Window_InnerCoordinate) + X and clip to the monitor, if needed.
But don't do it for me.I have other little details that don't suit me completely, like the return with the Cancel button: *UserChoice.Integer
Code: Select all
Define UserChoice.Integer
UserChoice\i = 1
Debug FontRequesterEx("Segoe UI Semibold,12", #ZFR_FontRequester_Effects, 0, 1, 1, @UserChoice)
If UserChoice\i
Debug SelectedFontNameEx() + ", " + Str(SelectedFontSizeEx()) + ", " + Str(SelectedFontStyleEx())
EndIf
Rather than just ProcedureReturn = “”
Code: Select all
If FontRequesterEx("Segoe UI Semibold,12", #ZFR_FontRequester_Effects, 0, 1, 1)
Debug SelectedFontNameEx() + ", " + Str(SelectedFontSizeEx()) + ", " + Str(SelectedFontStyleEx())
EndIf
Re: An alternative FontRequester [Windows only]
Posted: Fri Mar 14, 2025 2:44 pm
by AZJIO
ChrisR wrote: Fri Mar 14, 2025 12:52 pm
However I've never really understood the point of defining a parent window, except creating a dummy window to bypass the default positioning.
AutoIt3 has always used the parent window handle, and I couldn't imagine any other option. It was unclear to me how you can create a window without having a parent. The point of such a window is to close the child windows along with the parent window in some cases, but for me the main point was to block access to the parent window until a selection is made in the child window. This is called a modal window. If you do not do this, you can open several windows and forget about them, and then turn on data processing in the main window, while the algorithm, having received no data from previously opened windows, will continue to work without using this data. Therefore, these windows prevent further actions until you close the window by agreeing to the current selection or deselecting the selection.
Specifying the parent window is not responsible for window positioning.
When you lock the parent window, it stops receiving notifications from window elements and the mouse cursor and does not write in the window title that the window is frozen.
Re: An alternative FontRequester [Windows only]
Posted: Fri Mar 14, 2025 4:45 pm
by ChrisR
My bad, you are right about the modal window.
On the other hand, I don't agree with: Specifying the parent window is not responsible for window positioning
Try this code snippet, without the DPIAware flag:
Code: Select all
If OpenWindow(0, 100, 0, 220, 50, "FontRequester", #PB_Window_SystemMenu)
ButtonGadget(0, 10, 10, 200, 30, "FontRequester Step 0/3")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 0 ; FontRequester
Select Stage
Case 0
Font = FontRequester(FontName$, FontSize, 0, 0, FontStyle)
ResizeWindow(0, 100, 744, #PB_Ignore, #PB_Ignore) ; y=744 for my 1920*1080 screen to have it at the bottom
Case 1
Font = FontRequester(FontName$, FontSize, 0, 0, FontStyle)
ResizeWindow(0, 100, 0, #PB_Ignore, #PB_Ignore)
Case 2
;390*496
DisableWindow(0, #True)
DummyWindow = OpenWindow(#PB_Any, 100, -54, 0, 0, "", #PB_Window_Invisible|#PB_Window_NoActivate)
Font = FontRequester(FontName$, FontSize, 0, 0, FontStyle, WindowID(DummyWindow))
CloseWindow(DummyWindow)
ResizeWindow(0, 100, 744, #PB_Ignore, #PB_Ignore) ; y=744 for my 1920*1080 screen to have it at the bottom
DisableWindow(0, #False)
SetActiveWindow(0)
Case 3
DisableWindow(0, #True)
DummyWindow = OpenWindow(#PB_Any, 100, 182, 0, 0, "", #PB_Window_Invisible|#PB_Window_NoActivate)
Font = FontRequester(FontName$, FontSize, 0, 0, FontStyle, WindowID(DummyWindow))
CloseWindow(DummyWindow)
ResizeWindow(0, 100, 0, #PB_Ignore, #PB_Ignore)
DisableWindow(0, #False)
SetActiveWindow(0)
EndSelect
Stage = (Stage+1)%4
SetGadgetText(0, "FontRequester Step " + Str(Stage) + "/3")
If Font
FontName$ = SelectedFontName() : FontSize = SelectedFontSize() : FontStyle = SelectedFontStyle()
Debug FontName$ + ", " + FontSize + ", " + FontStyle
LoadFont(0, FontName$, FontSize, FontStyle)
SetGadgetFont(0, FontID(0))
Else
FontName$ = "" : FontSize = 0 : FontStyle = 0
SetGadgetFont(0, #PB_Default)
EndIf
EndSelect
EndSelect
ForEver
EndIf
Re: An alternative FontRequester [Windows only]
Posted: Fri Mar 14, 2025 5:19 pm
by Zapman
So, the right point off view is probably that specifying the parent window can respond to different needs.
I'm not able to share a new version of the code at this moment, but it seems to me, ChrisR, that the fonctions 'ZapmanFontRequester()', 'ZapmanFontName()', 'ZapmanFontSize()' and 'ZapmanFontStyle()' which already exist, should reply to your need. Don't they?
You can also use the 'ZFR_FontDescription$' global variable to get the result.
Re: An alternative FontRequester [Windows only]
Posted: Fri Mar 14, 2025 5:30 pm
by AZJIO
ChrisR
It was a long time ago, I used WindowsXP, as well as various dialog boxes. Therefore, I cannot say for sure now whether the font selection window was positioned near the parent window. I just checked the AutoIt3 color selection window and it was positioned next to the parent window. But I remember for sure that when I specified the parent window for my own window and for the message window, they were never positioned next to the parent, they were always in the center of the screen.
Re: An alternative FontRequester [Windows only]
Posted: Sat Mar 15, 2025 11:19 am
by Zapman
Hi, ChrisR,
I updated the code. Here is the comment figuring in the full commented version for both procedures FontRequesterEx() and ZapmanFontRequester():
(full commented is available at
https://www.editions-humanis.com/downlo ... uester.zip)
; * If ParentWindow is a valid window number, the new window will be centered to it,
; and then shifted by XShiftOrPos and YShiftOrPos.
; * If ParentWindow = #PB_Default and GetActiveWindow() returns a valid window number,
; the new window will be centered to GetActiveWindow() and then shifted by XShiftOrPos and YShiftOrPos.
; * If ParentWindow = #PB_Default and GetActiveWindow() does NOT return a valid window number,
; the new window will be centered to the main screen and then shifted by XShiftOrPos and YShiftOrPos.
; * It ParentWindow = -2, XShiftOrPos and YShiftOrPos will be the absolute coordinates of the new window.
; * If ParentWindow = -3, the new window will be centered to the main screen and then shifted by XShiftOrPos
; and YShiftOrPos, whatever GetActiveWindow() is valid or not.
Re: An alternative FontRequester [Windows only]
Posted: Sat Mar 15, 2025 12:23 pm
by ChrisR
Thank you, looks good on paper.
I'll try it later, I'm running out of time this weekend.
Re: An alternative FontRequester [Windows only]
Posted: Sat Mar 15, 2025 3:04 pm
by Zapman
ChrisR wrote: Sat Mar 15, 2025 12:23 pm
I'll try it later, I'm running out of time this weekend.
Same for me, I'm visiting Rome

Re: An alternative FontRequester [Windows only]
Posted: Sat Mar 15, 2025 6:17 pm
by ChrisR
Nice city, have a good visit, you have the marathon if you want, I have a friend who is running there tomorrow
Re: An alternative FontRequester [Windows only]
Posted: Sun Mar 16, 2025 7:19 pm
by Zapman
The code has been updated.
The parent window is now disabled until the user click on Cancel or OK, has it is done for the original FontRequester.
Re: An alternative FontRequester [Windows only]
Posted: Sun Mar 16, 2025 7:19 pm
by Zapman
[]
Re: An alternative FontRequester [Windows only]
Posted: Mon Mar 17, 2025 10:47 am
by Zapman
The code has been updated. There was bugs in the window positionning management.