I have a memo field where instructions on how to use my GUI can be displayed. I have both horizontal and vertical scroll bars enabled for the memo. Both scroll bars show as the instructions are detailed and exceed the frame both vertically and horizontally. However, the vertical scroll bar is always at the bottom, and so unless the user scrolls up, he will miss the instructions at the beginning. The horizontal scroll bar is correctly at the left. Is there some property of the memo that I need to change in the Object Inspector to ensure that the vertical bar is on top so that the user can read the instructions from the beginning?
I have saved the instructions as a string called Instructions. I copy this string into the memo by means of the following code:
procedure TfrmHSR.mmuDispInstructionsClick(Sender: TObject); //display instructions in Memo field var DispText: string; begin Memo1.Clear; DispText := Wraptext(Instructions, 125); Memo1.Lines.Add(DispText); mmuDisplayClear.Enabled := True; mmuFileSave.Enabled := False; //if input file created and opened, allow display of input data if Assigned(InputFile) then //if TStringList has been created begin if (InputFile.Count > 0) then mmuDispData.Enabled := True else mmuDispData.Enabled := False; end else mmuDispData.Enabled := False; //if results available, allow display if Assigned(OutputFile) then //if TStringList has been created begin if (OutputFile.Count > 0) then mmuDispResults.Enabled := True else mmuDispResults.Enabled := False; end else mmuDispResults.Enabled := False; mmuDispInstructions.Enabled := False; end;
Memo.Perform(EM_SETSEL, 0, 0); Memo.Perform(EM_SCROLLCARET, 0, 0);after you add the lines.the codewhere I've reproduced your problem and where I've been able to move the caret to top. (however, as Ken said, in that code usingClearandAddis useless; coincidentally Ipointed thisout today).