The order the values are saved surely has no effect. It is the order the properties are loaded that could have any effect. I decided to use Setbounds because this is faster than setting each of the 4 properties separately and I don't think it will make any difference to do so.
If you say that setting the 4 properties does work on Win2k then the only thing left is the setting of the WindowState. Perhaps this needs to be set after the form is shown. I realize now that I have some code for Win9x only to set the WindowState after the form is shown. I forgot about this as it was done some time ago. What was happening on Win98 was that the Window was shown in it's restored size, but with the center titlebar button set as if it was maximized. I have access to Win98 here so I could test it until I found the solution, but I do not have Win2k to do multiple tests on. Regards, Ross. ----- Original Message ----- From: "Robert Meek" <[EMAIL PROTECTED]> To: "'Borland's Delphi Discussion List'" <[email protected]> Sent: Saturday, October 22, 2005 6:00 AM Subject: RE: Win2k window problems I think the only way you're going to find out is by taking it down to it's simplest form. Simply saving it's Top, Let, Height, and Width values right before the form is closed, and resetting them in the form's OnCreate, making sure to reassign these values at OnCreate in the same order they were original saved. That is the purest way of doing this and it DOES work under the W2k OS providing nothing else is causing problems elsewhere. So if it works, and you still must alter it to the way you wish to hanf=dle it, do so my exchanging one line at a time until you find where the problem first occurs. from: Robert Meek at: [EMAIL PROTECTED] dba "Tangentals Design" home of "PoBoy" freeware Windows apps and utilities located at: www.TangentalsDesign.com Proud to be a moderator for the "Delphi Programming Lists" at: elists.org -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ross Levis Sent: Thursday, October 20, 2005 8:56 PM To: Borland's Delphi Discussion List Subject: Re: Win2k window problems Well I thought the following change would have fixed it, but I found out today that it made no difference. This is what I'm doing. Firstly to Save the window sizes and positions. with WindowPlacement do begin GetWindowPlacement(MyForm.Handle, @WindowPlacement); Reg.WriteInteger(Prefix+'Top',rcNormalPosition.Top); Reg.WriteInteger(Prefix+'Left',rcNormalPosition.Left); Reg.WriteInteger(Prefix+'Bottom',rcNormalPosition.Bottom); Reg.WriteInteger(Prefix+'Right',rcNormalPosition.Right); Reg.WriteInteger(Prefix+'State',Ord(MyForm.WindowState)); end; To load the Windows sizes and positions: aLeft := Reg.ReadInteger(Prefix+'Left'); aTop := Reg.ReadInteger(Prefix+'Top'); aWidth := Reg.ReadInteger(Prefix+'Right') - aLeft; aHeight := Reg.ReadInteger(Prefix+'Bottom') - aTop; MyForm.SetBounds(aLeft,aTop,aWidth,aHeight); MyForm.WindowState := TWindowState(Reg.ReadInteger(Prefix+'State')); So I've got no ideas why you can't do this on Win2k, yet works on all other Windows versions from Win95 to WinXP and Win2003. I'm wondering if it is the change of WindowState while the form is not visible that may be causing the problem. Or perhaps it is something to do with this routine being run from the DPR file before the Application.Run but after all the forms are created. Perhaps the mainform needs to be visible on Win2k before a change to the window size can be made. Changing the routine to run after the mainform is visible may solve it, but it wouldn't look nice seeing it resize or move position after it is shown. Anyone with further ideas? Regards, Ross. ----- Original Message ----- From: "Robert Meek" <[EMAIL PROTECTED]> To: "'Borland's Delphi Discussion List'" <[email protected]> Sent: Wednesday, October 19, 2005 4:55 AM Subject: RE: Win2k window problems Well I wouldn't call it overkill! I've been in similar situation though, where after wasting a day or two trying to solve a persnickety problem I've become frustrated and decided to drop the particular feature causing the problems. The next day however I feel so guilty I always would go back to it again! <g> And though I have never worried about this particular situation myself, that is, not saving position when maximized at closure, I think it's a great little addition for almost any application and since you brought it up I'm going to add it to my base template code! Let me know if and how you do finally solve it! from: Robert Meek at: [EMAIL PROTECTED] dba "Tangentals Design" home of "PoBoy" freeware Windows apps and utilities located at: www.TangentalsDesign.com Proud to be a moderator for the "Delphi Programming Lists" at: elists.org -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ross Levis Sent: Monday, October 17, 2005 7:36 PM To: Borland's Delphi Discussion List Subject: Re: Win2k window problems Yeah, it's probably overkill what I'm doing. The advantage is that if a user resizes some forms manually by draging the window edges, but then sometimes maximizes a form, the size of the non-maximized form is saved, so it works just like the app was never closed, if you see what I mean. A Restore will restore the form to the size the user adjusted it to before the Maximize. It works quite nicely, except on Win2k. Ross. ----- Original Message ----- From: "Robert Meek" <[EMAIL PROTECTED]> To: "'Borland's Delphi Discussion List'" <[email protected]> Sent: Monday, October 17, 2005 9:14 PM Subject: RE: Win2k window problems How about adding a simple test to the saving code? If WindowState - wsMaximized then Exit Else Run Savecode; from: Robert Meek at: [EMAIL PROTECTED] dba "Tangentals Design" home of "PoBoy" freeware Windows apps and utilities located at: www.TangentalsDesign.com Proud to be a moderator for the "Delphi Programming Lists" at: elists.org -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ross Levis Sent: Sunday, October 16, 2005 6:14 PM To: Borland's Delphi Discussion List Subject: Re: Win2k window problems I use to use the simple option of settings the forms Top, Left, Height, and Width, but if the window was maximized when the app was closed, it would save the size of the full screen, so there is no easy way for the user to restore to the original position before the maximize. Storing and loading the rcNormalPosition, and the WindowState solves that problem. I suppose I could try using alClient Alignment. I do have controls above and below the listview which could go into separate panels if necessary. I'm not sure if it will make any difference but I will try this and send it to a user for testing. The Anchors should still work though. I'm wondering if the bug in Win2k is due to the SetWindowPlacement being done too close to the change of WindowState. Perhaps the WindowState is non-modal and is performing operations while the WindowState is being set and stuffs something up. A Sleep() may solve it. I didn't mention it as I don't think it's related but I'm also restoring the column positions of the listview immediately after the main form sizing and positioning. I was hoping someone else had used SetWindowPosition and come across this problem on Win2k with a solution, but it appears not. Something I just thought of may work. I could store the rcNormalPosition but convert this into Height (Bottom - Top) and Width (Right - Left) when loading the figures and use the standard Form properties. This will likely fix it properly. Regards, Ross. ----- Original Message ----- From: "Robert Meek" <[EMAIL PROTECTED]> To: "'Borland's Delphi Discussion List'" <[email protected]> Sent: Monday, October 17, 2005 5:52 AM Subject: RE: Win2k window problems I think you should be resetting the form's Top, Left, Height, and Width instead of as you are with the Bottom and Right. This always worked for me in Windows 95, 98, 2000 and XP. Make sure too that the alignment of your TListView is set to alClient. Just setting your anchors is NOT the same! If you can't align to alClient because of needing space between it and it's parent's borders, use panels or spacers in between so that you can. Also, I've experienced a lot of registry problems with Win2000. For example, even with Microsoft's own products when uninstalled, registry entries were not always cleaned up as they should be. So I stopped using the Registry except for those things that were absolutely necessary. For everything else I went back to inifiles and the only difference I noticed was an increase in speed! <g> from: Robert Meek at: [EMAIL PROTECTED] dba "Tangentals Design" home of "PoBoy" freeware Windows apps and utilities located at: www.TangentalsDesign.com Proud to be a moderator for the "Delphi Programming Lists" at: elists.org -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ross Levis Sent: Saturday, October 15, 2005 8:54 PM To: Delphi Discussion List Subject: Win2k window problems I have a problem which only occurs on Windows 2000 workstations. XP and Win9x work fine. I'm storing the window sizes and positions of several windows when closing my app. I'm using similar code to the following when my program loads: with WindowPlacement do //(TWindowPlacement) begin Length := Sizeof(WindowPlacement); rcNormalPosition.Top := Reg.ReadInteger('Top'); rcNormalPosition.Left := Reg.ReadInteger('Left'); rcNormalPosition.Bottom := Reg.ReadInteger('Bottom'); rcNormalPosition.Right := Reg.ReadInteger('Right'); showCmd := SW_HIDE; SetWindowPlacement(MyForm.Handle, @WindowPlacement); MyForm.WindowState := TWindowState(Reg.ReadInteger('State')); end; In one example, a form has a ListView which is anchored at Top, Left, Bottom, and Right. On Win2k (and only Win2k), the listview does not resize when the window is resized. It stays the same size so you end up with blank space to the right and bottom when the form is made bigger or maximized. It's as if the 4 Anchors are set to False. This only occurs after the above code is run. The reason for using SetWindowPlacement is so the restored size of the windows are stored and loaded regardless of whether the form is maximized or not. The user can then Restore to the original form size. I don't have Win2k here so it's my users who have reported this problem and I can't test any changes here to resolve it. Any ideas? Thanks, Ross. _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

