Hi Landfla,
I use this idea to manage the main window size, but it could easily be applied to others.
I have a table called STARTUP.DBF that has fields WINTOP, WINLEFT, WINHEIGHT, WINWIDTH.
At the start of the .EXE very early call, I open this DBF, read in its values and then use them to set the initial area with:
lnWinPositionTop = STARTUP.WINTOP
lnWinPositionLeft = STARTUP.WINLEFT
lnWinPositionHeight = STARTUP.WINHEIGHT
lnWinPositionWidth = STARTUP.WINWIDTH
I have a single record in my STARTUP.DBF, but what you could do is add a field like "WINDOWNAME" and then every time a window is opened, you could find it's WINDOWNAME and then make it's sizes that of the values in the STARTUP.DBF.
STARTUP is a free table, that you just open and close when you need it, so it's kind of a place I "stash" global variable (without making them PUBLICs). Just use when I need them. Then when the window is closed, at it's DEACTIVATE code, just do something like:
Code:
IF NOT USED("STARTUP")
SELECT 0
USE DBFS\STARTUP
SET ORDER TO WINDOWNAME && sets the index, but you'll need to create that index
ELSE
SELECT STARTUP
SET ORDER TO WINDOWNAME
ENDIF
*
SEEK THISFORM.NAME && (be careful to change the DEFAULT value of the name of a form, or they will all be the same)
REPLACE STARTUP.WINTOP with ThisForm.Top
REPLACE STARTUP.WINLEFT with ThisForm.Left
REPLACE STARTUP.WINHEIGHT with ThisForm.Height
REPLACE STARTUP.WINWIDTH with ThisForm.Width
*
SELECT STARTUP
USE
Now this does one thing you haven't mentioned... it also retains WHERE the window is so if you arrange your open windows in a particular way then it will retain that as well. Just make sure you change the default form name, as they will default to something like Form1 or <classname1> and they will all be the same in the STARTUP.DBF, so just make sure they are unique, and this should work fine.
Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS
"Everything should be made as simple as possible, and no simpler."
![[hammer] [hammer] [hammer]](/data/assets/smilies/hammer.gif)