[Gambas-user] an observation on window placement with multiple screens

Bruce Steers bsteers4 at gmail.com
Sun Nov 6 21:43:12 CET 2022


On Sun, 6 Nov 2022 at 20:05, Bruce Steers <bsteers4 at gmail.com> wrote:

>
>
> On Thu, 13 Oct 2022 at 14:17, bb <adamnt42 at gmail.com> wrote:
>
>> On Thu, 2022-10-13 at 14:42 +0200, Benoit Minisini wrote:
>> > Le 13/10/2022 à 14:03, Bruce Steers a écrit :
>>
>> Secondly, and more importantly as BruceS has intimated, there is no way
>> that I can control where modal popups or message windows appear. But my
>> wish would be this...
>> I would really like the popups to be centered in the window that called
>> the popup not just in the center of the screen. For example 1) when
>> using an extended screen across two "X terminals" popups appear
>> centered exactly on the entire screen. In other words, half on my
>> primary display and half on the extended display. This is bad enough if
>> both displays are running at the same resolution and worse if they are
>> not. For example 2) if I am running several instances of a project
>> tiled on the display (whether using an extended display or not) the
>> popup appears in the center of the screen. This gives me no indication
>> of which instance the message (for instance) belongs to. It would be
>> much more preferrable that it was in the center of the window that it
>> belongs to.
>>
>
> I figured out this Bruce..
> The attached project has a Form.class and an override for ShowModal()
> it checks if there is a calling window and notes it to get Window.Screen
> info.
>
> it creates a timer to move the window to the center of the correct calling
> screen on opening if not on the same screen.
>
> the attached project can be tested by moving the main window to a screen
> and hit the Message button to open a message box
>
> The override means it should operate on ANY ShowModal call your
> application does itself or triggers. (it certainly works for Message() )
>

Note:
You can make it only work on Message windows (and others you select) and
not All your other modal windows by inspecting the window name (Ie.
Message.class uses FMessage)

like so...

Public Sub ShowModal() As Integer

  If Application.ActiveWindow And if Me.Name = "FMessage" Then
    $actW = Application.ActiveWindow
    $MoveTimer = New Timer As "MTimer"
    $MoveTimer.Delay = 0
    $MoveTimer.Start
  Endif

  Return Super.ShowModal()

End

All the best.

BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221106/a5c7aec3/attachment.htm>


More information about the User mailing list