Page 1 of 1

Posted: Fri Dec 19, 2008 3:15 am
by Sparkie
akj wrote: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?
No bug, the code just needs a little adjustment...

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) 
cxFrame = GetSystemMetrics_(#SM_CXFIXEDFRAME) * 2
cyFrame = GetSystemMetrics_(#SM_CYFIXEDFRAME) * 2
cyCaption = GetSystemMetrics_(#SM_CYCAPTION)
If flags & #WS_THICKFRAME
  cxFrame = GetSystemMetrics_(#SM_CXFRAME) * 2
  cyFrame = GetSystemMetrics_(#SM_CYFRAME) * 2
EndIf

With info\rcNormalPosition 
  WritePreferenceInteger("WinX", \left) 
  WritePreferenceInteger("WinY", \top) 
  WritePreferenceInteger("Width", \right-\left-cxFrame) 
  WritePreferenceInteger("Height", \bottom-\top-cyFrame-cyCaption) 
EndWith 
ClosePreferences() 
End