我也遇到过这个问题,后来改RXRICHEDIT情况好一些些,但是仍然不行
再后来用如下搞定:
procedure TLogTabSheet.ShowMsg(strMsg:string;iColor:TColor);
var
// FirstLine:integer;
ScrollMessage:TWMVScroll;
// iStart:integer;
begin
// FirstLine:=SendMessage(rxLog.Handle,EM_GETLINECOUNT,0,0);
//要显示数据
ShowingData:=True;
//设置新数据的显示位置及颜色、字体、大小等等信息
//其中每次强制设置字体及大小可以防止在98系统中出现中文乱码的现象
rxLog.SelStart:=Maxint;
rxLog.SelAttributes.Color:=iColor;
rxLog.SelAttributes.Charset:=GB2312_CHARSET;
rxLog.SelAttributes.Name:='宋体';
rxLog.SelAttributes.Height:=12;
if bAutoScroll then
//取消自动刷新
sendmessage(rxLog.handle,wm_setredraw,0,0);
//加入显示数据
strMsg:=strMsg+#13#10;
sendmessage(rxLog.Handle,EM_REPLACESEL,0,lparam(pchar(strMsg)));
rxLog.SelStart:=Maxint;
if (bAutoScroll) then
begin
//自动滚动,滚动到SB_BOTTOM
windows.setfocus(rxLog.Handle);
ScrollMessage.Msg:=WM_VScroll;
ScrollMessage.ScrollCode:=SB_BOTTOM;
ScrollMessage.Pos:=0;
rxLog.Dispatch(ScrollMessage);
//如果不是NT系统,则滚动后要出现空白显示,再滚动PAGEUP,PAGEDOWN即可
if not bIsNt then
begin
sendmessage(rxLog.Handle,EM_SCROLL,sb_pageup,0);
sendmessage(rxLog.Handle,EM_SCROLL,SB_PAGEDOWN,0);
end;
end
else
begin
//不自动滚动,取消RXLOG的焦点即可
sendmessage(rxLog.Handle,wm_killfocus,rxLog.Parent.Handle,0);
end;
if bAutoScroll then
begin
//允许刷新
sendmessage(rxLog.handle,wm_setredraw,1,0);
//强制刷新
rxLog.Refresh;
end;
//显示数据结束
ShowingData:=False;
end;