这个问题我解决了,用的这个方法:<br>给memo发一个EM_SCROLL消息,如果返回值为true,表示可以滚动,那么添加滚动条<br>反之,取消滚动条<br>不过判断行高还是没搞定,如果那位高手能搞定的话,我还是会给分的<br>附我的代码:<br>procedure TfrmBaseChat.MsgOutChange(Sender: TObject);<br>var<br> idx: Integer;<br> CanScroll: Boolean;<br>begin<br> inherited;<br> idx := MsgOut.SelStart;<br> CanScroll := False;<br> if HiWord(SendMessage(MsgOut.Handle, EM_SCROLL, SB_LINEDOWN, 0)) = 1 then<br> begin<br> CanScroll := True;<br> SendMessage(MsgOut.Handle, EM_SCROLL, SB_LINEUP, 0);<br> end<br> else if HiWord(SendMessage(MsgOut.Handle, EM_SCROLL, SB_LINEUP, 0)) = 1 then<br> begin<br> CanScroll := True;<br> SendMessage(MsgOut.Handle, EM_SCROLL, SB_LINEDOWN, 0);<br> end;<br> if CanScroll and (MsgOut.ScrollBars = ssNone) then<br> begin<br> MsgOut.ScrollBars := ssVertical;<br> MsgOut.SelStart := idx;<br> MsgOut.SelLength := 0;<br> end<br> else if not CanScroll and (MsgOut.ScrollBars = ssVertical) then<br> begin<br> MsgOut.ScrollBars := ssNone;<br> MsgOut.SelStart := idx;<br> MsgOut.SelLength := 0;<br> end;<br>end;<br>