Set Requester Position ...
Set Requester Position ...
...to init default position of requesters
or add optional parameter x,y
or add optional parameter x,y
Last edited by eddy on Wed Jun 25, 2003 10:51 am, edited 1 time in total.
Re: SetRequesterPosition
The Problem is, that the API don't give the posibility (or only with much, much code)eddy wrote:...to init default position of requesters
or add optional parameter x,y
Re: SetRequesterPosition
> ...to init default position of requesters
All the requesters are based on API calls, as GPI said. For Fred to make
them open in an X-Y position, he'd have to create custom requesters.
There are ways to force the position of some of them, for example:
viewtopic.php?t=6278
All you need is some creative coding.
All the requesters are based on API calls, as GPI said. For Fred to make
them open in an X-Y position, he'd have to create custom requesters.
There are ways to force the position of some of them, for example:
viewtopic.php?t=6278
All you need is some creative coding.

Re: SetRequesterPosition
I used this to center a Requester (But you need the Window Name of it):PB wrote:All you need is some creative coding.
Code: Select all
; If you know the Window name of a Requester you can place it...
; (c) 2003 - Franco's Template - absolutely free
Procedure CenterFutureWindowThread(WindowTitle$)
Repeat
WindowID = FindWindow_(0,WindowTitle$)
Pos.RECT : GetWindowRect_(WindowID,Pos)
SetWindowPos_(WindowID,#HWND_TOPMOST,(GetSystemMetrics_(#SM_CXSCREEN)/2)-((Pos\right-Pos\left)/2),(GetSystemMetrics_(#SM_CYSCREEN)/2)-((Pos\bottom-Pos\top)/2),Pos\right-Pos\left,Pos\bottom-Pos\top, 0)
;MoveWindow_(WindowID,(GetSystemMetrics_(#SM_CXSCREEN)/2)-((Pos\right-Pos\left)/2),(GetSystemMetrics_(#SM_CYSCREEN)/2)-((Pos\bottom-Pos\top)/2),Pos\right-Pos\left,Pos\bottom-Pos\top, #TRUE)
ShowWindow_(WindowID,#SW_SHOW)
Until WindowID
EndProcedure
ThreadID=CreateThread(@CenterFutureWindowThread(),"Browse for Folder")
OpenProject$ = PathRequester("Select Directory:", Path$)
KillThread(ThreadID)
I am to provide the public with beneficial shocks.
Alfred Hitshock
Re: Set Requester Position ...
Franco and fsw's code updated for 2022:
Code: Select all
Procedure CenterFutureWindowThread(WindowTitle)
WindowTitle$=PeekS(WindowTitle)
Repeat
WindowID = FindWindow_(0,WindowTitle$)
Pos.RECT : GetWindowRect_(WindowID,Pos)
SetWindowPos_(WindowID,#HWND_TOPMOST,50,50,300,400,0)
ShowWindow_(WindowID,#SW_SHOW)
Until WindowID
EndProcedure
ThreadID=CreateThread(@CenterFutureWindowThread(),@"Browse for Folder")
OpenProject$ = PathRequester("Select Directory:", Path$)
Debug OpenProject$
Re: Set Requester Position ...
That's really old Windows code, glad it still works.
Now I'm on a Mac and could have used such code for macOS in the past.
Before this forum there was another one but something happened to it.
Fred was able to rescue the content but not the users names...
Now I'm on a Mac and could have used such code for macOS in the past.

Franco was the alias I used to use in the old forum.
Before this forum there was another one but something happened to it.
Fred was able to rescue the content but not the users names...
I am to provide the public with beneficial shocks.
Alfred Hitshock
Re: Set Requester Position ...
For MacOS you may use the following code to display a modal requester (NSAlert) at a specified position (successfully tested on MacOS 11.7 'Big Sur' with PB 6.00):fsw wrote: Mon Oct 24, 2022 1:37 am Now I'm on a Mac and could have used such code for macOS in the past.
Code: Select all
EnableExplicit
Define MenuBarHeight.CGFloat
Define Point.NSPoint
Define Requester.I
Define RequesterWindow.I
Define RequesterWindowFrame.NSRect
; ----- Create requester using NSAlert
Requester = CocoaMessage(0, CocoaMessage(0, 0, "NSAlert new"), "autorelease")
CocoaMessage(0, Requester, "setMessageText:$", @"Requester demo")
CocoaMessage(0, Requester, "setInformativeText:$",
@"This requester is displayed at position x=100 and y=100")
CocoaMessage(0, Requester, "addButtonWithTitle:$", @"OK")
Point\x = 100
; ----- Get height of menu bar
CocoaMessage(@MenuBarHeight.CGFloat, CocoaMessage(0, CocoaMessage(0, 0,
"NSApplication sharedApplication"), "mainMenu"), "menuBarHeight")
; ----- Calculate inverse y coordinate of requester
ExamineDesktops()
RequesterWindow = CocoaMessage(0, Requester, "window")
CocoaMessage(@RequesterWindowFrame, RequesterWindow, "frame")
Point\y = DesktopHeight(0) - MenuBarHeight - RequesterWindowFrame\size\height - 100
; ----- Display requester
CocoaMessage(0, RequesterWindow, "setFrameOrigin:@", @Point)
CocoaMessage(0, RequesterWindow, "makeKeyAndOrderFront:", 0)
CocoaMessage(0, Requester, "runModal")
Re: Set Requester Position ...
This works nice.
Thank you Shardik.
Thank you Shardik.
I am to provide the public with beneficial shocks.
Alfred Hitshock