message window on wrong monitor

Post

Posted
Rating:
#1 (In Topic #709)
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 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?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
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: -

Code (gambas)

  1. ' Gambas class file
  2.  
  3. NewMessage As Form
  4. Button1 As Button
  5. Button2 As Button
  6. Label1 As Label
  7.  
  8. Public Sub Form_Open()
  9.  
  10.   With Me
  11.     .Height = 400
  12.     .Width = 500
  13.     .Padding = 5
  14.     .Arrangement = Arrange.None
  15.     .Center
  16.  
  17.   With Button1 = New Button(Me) As "Button1"
  18.     .X = 200
  19.     .Y = 350
  20.     .H = 28
  21.     .W = 112
  22.     .Text = "&Click me!"
  23.  
  24.  
  25. Public Sub Button1_Click()
  26.  
  27.   With NewMessage = New Form As "NewMessage"
  28.     .H = 100
  29.     .W = 350
  30.     .Show
  31.  
  32.   With Label1 = New Label(NewMessage) As "Label1"
  33.     .X = 10
  34.     .Y = 15
  35.     .H = 28
  36.     .W = 350
  37.     .Font.Size = 16
  38.     .Alignment = Align.Center
  39.     .Text = "Hey, you forgot something."
  40.  
  41.   With Button2 = New Button(NewMessage) As "Button2"
  42.     .X = 200
  43.     .Y = 70
  44.     .H = 28
  45.     .W = 112
  46.     .Text = "&OK"
  47.  
  48.  
  49. Public Sub Button2_Click()
  50.  
  51.   NewMessage.Close
  52.  
  53.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
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.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
stevedee is in the usergroup ‘Regular’

sadams54 said

…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

wmctrl -r :ACTIVE: -t 2

…will send active window to workspace 3 …I can't remember whether extra monitors are like additional workspaces.
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’

sadams54 said

…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

frmMessage.Left = Screen.Width * MonitorNumber
…assuming monitors numbered from zero
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Enthusiast
PJBlack is in the usergroup ‘Enthusiast’

sadams54 said

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
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
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.
Online now: No Back to the top
1 guest and 0 members have just viewed this.