Page 1 of 1

message window on wrong monitor

Posted: Wednesday 21st July 2021 11:20pm
by sadams54
I have programs written to take advantage of multiple monitors on a system. The problem I have is that I do not seem to be able to control where a standard message window appears. It seems to always appear on the wrong monitor leaving people looking for where the message is at so they can hit ok or cancel etc. Is there a way to control where the window appears?

example...
message.info("Hey, you forgot something") This appears somewhat randomly and never where I want to place it. How can I make it go where I want it?

Re: message window on wrong monitor

Posted: Thursday 22nd July 2021 2:05pm
by cogier
I don't have a multi monitor system, but I wondered if you create a new Form for your message.info("Hey, you forgot something") instead of relying on the internal message.

Try this as a possible solution: -
' Gambas class file

NewMessage As Form
Button1 As Button
Button2 As Button
Label1 As Label

Public Sub Form_Open()

  With Me
    .Height = 400
    .Width = 500
    .Padding = 5
    .Arrangement = Arrange.None
    .Center
  End With

  With Button1 = New Button(Me) As "Button1"
    .X = 200
    .Y = 350
    .H = 28
    .W = 112
    .Text = "&Click me!"
  End With

End

Public Sub Button1_Click()

  With NewMessage = New Form As "NewMessage"
    .H = 100
    .W = 350
    .Show
  End With

  With Label1 = New Label(NewMessage) As "Label1"
    .X = 10
    .Y = 15
    .H = 28
    .W = 350
    .Font.Size = 16
    .Alignment = Align.Center
    .Text = "Hey, you forgot something."
  End With

  With Button2 = New Button(NewMessage) As "Button2"
    .X = 200
    .Y = 70
    .H = 28
    .W = 112
    .Text = "&OK"
  End With

End

Public Sub Button2_Click()

  NewMessage.Close

End

Re: message window on wrong monitor

Posted: Thursday 22nd July 2021 5:53pm
by sadams54
I was actually looking to do that today but using the internal is just so much easier. However I was planning on making a universal message and input box setup in the mean time.

Re: message window on wrong monitor

Posted: Thursday 22nd July 2021 6:08pm
by stevedee
sadams54 wrote:
Wednesday 21st July 2021 11:20pm
...Is there a way to control where the window appears?
I don't know, but take a look at wmctrl which can move the active window to another workspace;

Code: Select all

wmctrl -r :ACTIVE: -t 2
...will send active window to workspace 3 ...I can't remember whether extra monitors are like additional workspaces.

Re: message window on wrong monitor

Posted: Thursday 22nd July 2021 8:18pm
by sadams54
in this case workspaces and monitors are very different. so that would not work. I have attempted to use extensions that will move things to the right place but they do not affect dialogs which is what this is.
when using multiple monitors the x and or y attributes are essentially doubled making the monitors a single entity. so to put something on a particular monitor you would have to set the x or y values beyond the first monitor and into the field of the desired monitor. So workspaces are totally different in that respect.

Re: message window on wrong monitor

Posted: Friday 23rd July 2021 10:21am
by stevedee
sadams54 wrote:
Thursday 22nd July 2021 8:18pm
...when using multiple monitors the x and or y attributes are essentially doubled making the monitors a single entity. so to put something on a particular monitor you would have to set the x or y values beyond the first monitor and into the field of the desired monitor...
OK, I'm probably missing something here, but if the display is just spread over a number of monitors, why can't you do what you say above?
e.g. to place form on required display

Code: Select all

frmMessage.Left = Screen.Width * MonitorNumber
...assuming monitors numbered from zero

Re: message window on wrong monitor

Posted: Friday 23rd July 2021 11:05am
by PJBlack
sadams54 wrote:
Wednesday 21st July 2021 11:20pm
This appears somewhat randomly
some strange twisted logic is definitely behind it ... maybe the messagebox appears on the monitor where the application with the focus is running?

if i skimmed the qt documentation correctly there is no way to determine the position there either ... so if you really want to define where the messagebox appears you have to program it yourself ...

interesting should be the calculation of the monitor ... negative x values for everything left of the primary monitor plus the respective y offsets for the different vertical positions ... well have fun

Re: message window on wrong monitor

Posted: Friday 23rd July 2021 5:49pm
by sadams54
I ended up making my own inputbox and message so I can control where they go on a monitor or which monitor. The built in input and message do not have that ability and show up in unpredictable places. I modeled mine after the built in using same parameters so all I had to do was search and replace the name of the feature. Indeed the x and y position works that is how I control everything now but that option does not exist on the input and message that is built in. The idea to control it that way is sound but just not available. So as I said, I bit the bullet and made my own that does exactly what is needed.