Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ getting position of window after auto-positioning

getting position of window after auto-positioning

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zimmy   (31 posts)  Bio
Date Fri 24 Apr 2020 05:56 AM (UTC)
Message

win = "plugin_id"
WindowCreate(win, 0, 0, 0, 0, miniwin.pos_center_all, 0, ColourNameToRGB("black")) 
print(WindowInfo(win, 10), WindowInfo(win, 11))


The window is in the middle of the screen but this gives me 0, 0. How I can I find it's actual position?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 24 Apr 2020 09:51 AM (UTC)

Amended on Fri 24 Apr 2020 09:52 AM (UTC) by Nick Gammon

Message

According to the documentation for WindowInfo:

InfoType 10 to 13 are where the auto positioning last placed the window (the last time the main screen was refreshed).

Since the auto positioning is calculated each time the screen is redrawn it cannot be known the moment after you do the WindowCreate. The screen will not be redrawn in the middle of running a script (unless you call Repaint). Plus, you haven’t “shown” the window yet with WindowShow, so even if the screen refreshed the position would not be calculated.

For the code to work the way you are trying to use it, you have to both show the window, and also cause it to be displayed, with the Repaint function. So:

That will display the correct coordinates.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zimmy   (31 posts)  Bio
Date Reply #2 on Fri 24 Apr 2020 09:23 PM (UTC)

Amended on Fri 24 Apr 2020 09:24 PM (UTC) by Zimmy

Message
Thanks, I was getting weirdness with my resize handler if the mini-window had not yet been re-positioned with my drag move handler. Adding this at the beginning of my resize handler did the trick:

local auto_pos = WindowInfo(win, 7)
if auto_pos ~= 0 then 
   Repaint()
   WindowPosition(win, WindowInfo(win, 10), WindowInfo(win, 11), 0, 2)
end
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,149 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.