Thank you Sparkie, the use of GetWindowPlacement_() solved it. My resulting code is:
Code: Select all
Define flags, info.WINDOWPLACEMENT
flags = #PB_Window_SystemMenu|#PB_Window_TitleBar
flags | #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget
flags | #PB_Window_SizeGadget
OpenWindow(0, 100, 200, 300, 400, "Test", flags)
CreatePreferences("myfile.ini")
info\length = SizeOf(WINDOWPLACEMENT)
GetWindowPlacement_(WindowID(0), @info)
With info\rcNormalPosition
WritePreferenceInteger("WinX", \left)
WritePreferenceInteger("WinY", \top)
WritePreferenceInteger("Width", \right-\left-2*GetSystemMetrics_(#SM_CXFRAME))
WritePreferenceInteger("Height", \bottom-\top-2*GetSystemMetrics_(#SM_CYFRAME)-GetSystemMetrics_(#SM_CYCAPTION))
EndWith
ClosePreferences()
End
Incidentally, if the OpenWindow() flag #PB_Window_SizeGadget is omitted, then the width and height saved in the .INI file are 298, 398 rather then the correct 300, 400. Could this be a previously unnoticed PureBasic bug?