FS#6229 - [Windows] OpenTTD not store position on screen

Attached to Project: OpenTTD
Opened by Moshe L (admini) - Saturday, 07 February 2015, 18:13 GMT
Last edited by andythenorth (andythenorth) - Friday, 06 April 2018, 15:28 GMT
Type Feature Request
Category Interface
Status New
Assigned To andythenorth (andythenorth)
Operating System Windows
Severity Very Low
Priority Low
Reported Version 1.4.4
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No



I am using OpenTTD 1.4.4 (and all lower versions) on large screen, and prefer to use some position on the screen.

close& open, the size is correct but the position on the screen is the center from top and center from left, while ignoring original position or windows taskbar.

can be tested in any version, move, close, open.

This task depends upon

Comment by Inżynier Germanista (inz_germanista) - Sunday, 08 February 2015, 14:23 GMT
It's not due to OpenTTD itself but MS Windows and it's Window Placement. I'm using Linux and it's Compiz Window Manager has build in plugin to place any chosen program window excacly in the fixed place on the desktop every time the window is opened. Try find some software that would add this functionality to MS Windows or write it yourself if you know any programing language, it's not hard but requires usage of WinAPI.

For excample: but it's comercial solution that costs $10 to buy. Trial is fully functional during the evaluation period.
Comment by Vid the Kid (vtk) - Wednesday, 04 March 2015, 20:55 GMT
Firefox seems to restore its exact previous window positions when restoring session on launch. I'm boldly assuming the Windows API call to achieve a specific position (rather than whatever position Windows wants) for a created window is trivial. Note, care should be taken to prevent the window from appearing completely off-screen (such as, if the user is running a much lower screen resolution than the last time OpenTTD was run).
Comment by Inżynier Germanista (inz_germanista) - Thursday, 05 March 2015, 09:44 GMT
Of course there is something in WinAPI, to be excact each window has four integer variables (Top, Left, Width and Hight) and there is also SetWindowPos function in WinAPI to override current position and size of window and GetClientRect function to retrive current values (as they are WinAPI they require handle to window as a parameter). And no, there isn't WinAPI function to archive the goal. Applications that can do such thing with itself and it's windows calls those two function, GetClientRect before quiting and store those values somewhere (application ini file, windows register, wherever) and after the application is once more time opened and MS-Windows done with placing the app's windows where it likes to be placed application itsefl calls the SetWindowPos function with previous saved values, this is the only solution. This is the only solution and its common knowledge allong programers working with MS-Windows. Borland's VCL has for excample possibility to make TForm shown in predesigned place, but it's mechanism does the same thing but uses values stored as constants in application binaries (.exe file).
The comercial solution I gave above does excacly the same thing but as it doesn't know when application is about to be clesed then it sets a hook on each supported (chosen by user) application and when in the communicates query there is MoveWindow saves the rect of last one on the query (the one with final destantion and size of window) and if it detects the application is reopened it sets the values back to last saved value.
Now you know how it works, and if you know any programing language you can write yourself such tool to operate with OpenTTD. I won't do such thing because I don't need this since Compiz Window Placement does it for me and I don't have time to write some app that isn't needed by myself. And also I'm preety sure that this function if programed wouldn't be included in OpenTTD because it's strictly MS-Windows only feature to override one of huge collection of MS's OS design flosses. By the way WinAPI has only two functions that overrides default (stupid) window placement mechanism: Title all windows and Cascede them, and all of those is since Windows 3.0.
Comment by andythenorth (andythenorth) - Saturday, 19 August 2017, 08:02 GMT
See also /task/4721
Comment by andythenorth (andythenorth) - Saturday, 19 August 2017, 08:06 GMT
Cleaning Flyspray. This is OS specific, so setting it to low priority. Leaving it open as the request seems to come up moderately frequently, might be solvable in future.