Bart Kindt 5 Posted 14 hours ago I have a simple test Form with two TMemo's. The top TMemo align is set as alClient. The second is set as alBottom. In between I put a TSplitter. I want to set the vertical position of the splitter at runtime. Basically, I want to save the form, and later load it so the two Memo's are set as the User may have set them before. No matter what I try, I cannot make the Splitter or either of the Memo's to change size (vertically). They do not respond to any runtime setting of 'Top', Height, etc. Really, if I set the bottom TMemo.Top at a position, the top TMemo should automatically change size to accomodate. Does not work. I must be missing something totally obvious. unit Unit2; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls; type TForm2 = class(TForm) Memo1: TMemo; Memo2: TMemo; GroupBox1: TGroupBox; Button1: TButton; Splitter1: TSplitter; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.Button1Click(Sender: TObject); begin Splitter1.top := 100; // Does not work Memo2.top := 100; // Does not work Memo1.Height := 100; // Does not work end; end. Share this post Link to post
dummzeuch 1629 Posted 12 hours ago You must set the height of the memo with alBottom. Everything else will adjust automatically (unless the splitter acts up then it will be moved above the memo with alClient 😞 in that case you can hopefully set the splitter's top position to move it back between the memos where it belongs). 2 Share this post Link to post
Bart Kindt 5 Posted 9 hours ago Uh. I don't understand what you are saying. Show me what you mean in the code? Share this post Link to post
Bart Kindt 5 Posted 4 hours ago Yes, that worked. Still all kinds of weird behaviour. I had to put the two Memo's and splitter in a seperate Groupbox, else the bottom groupbox with the button in it would suddenly get above the bottom Memo and all is screwed. I also have to force the splitter Top to be above the bottom Memo top, minus the spiltter thickness. It is really messy, but it seems to work now. Thanks Share this post Link to post
Anders Melander 1974 Posted 3 hours ago 17 minutes ago, Bart Kindt said: Still all kinds of weird behaviour. Yes, I knew you would run into that problem. I just wanted to see if you could figure out the solution on your own 🙂 The behavior you observed is what @dummzeuch was alluding to. The reason is that once you have moved the controls the alignment is applied based on the current position of the controls. Since you have two bottom aligned controls (the splitter and the memo) then the topmost will always be aligned above the other. If you make the memo higher then the top position will be smaller than that of the splitter so you have to move the splitter too. The fact that you have the top control (instead of the bottom) client-aligned actually makes this a bit more complicated but never mind. Here's what you need to do to makes it work (I hope - alignment can be a bitch): You have 3 controls: MemoTop, align=client Splitter, align=bottom MemoBottom, align=bottom 1) Resize MemoBottom and manually reposition it so it is still bottom-aligned. 2) Reposition Splitter to be above MemoBottom. SavePos := MemoBottom.Top; DeltaSize := 100 - MemoBottom.Height; MemoBottom.Height := 100; MemoBottom.Top := SavePos - DeltaSize; Splitter.Top := MemoBottom.Top - Splitter.Height; Share this post Link to post