如何能使richedit只使用80列,比如我输入字符时,此行的字符超过80列自动换到下一行
解决方案 »
- PHP中crypt()加密函数delphi实现
- dbgrideh 单元格标注颜色
- 为什么把图片保存到数据库后,用DBImage 显示出来是黑的?急急急!
- 开发基于CMPP2.0短信系统,调用CMPPAPI出问题?
- 怎样才能像windows优化大师那样.把垃圾文件清理掉
- 有RSA解密算法,求RSA加密算法
- 字段类型为单精度数值型,设小数位数为2位,为什么会显示为2.1999456
- 还请大家多多帮助!我在使用ADO的时候,使用datamodule出错,但在每个窗体中使用ADO没问题,为什么?
- 各位大虾!!请问VCL具体指什么?而VCL扩展又具体指什么呢?
- 一个送分题!
- 强烈建议建立语音论坛室,大家认为如何?
- 流水账号的问题??急用呀???
Shift: TShiftState);
var i,j,k:integer;
begin
i:=richedit1.SelStart;
j:=0;
for k:=0 to richedit1.lines.count-1 do
begin
if j>i then
Break;
j:=j+length(richedit1.lines[k])+2;
end;
if k>0 then
begin
if length(richedit1.lines[k-1])=10 then
begin
// sendmessage(richedit1.handle,WM_CHAR,10,0);
sendmessage(richedit1.handle,WM_CHAR,13,0);
end;
end
else
if length(richedit1.lines[0])=10 then
begin
// sendmessage(richedit1.handle,WM_CHAR,10,0);
sendmessage(richedit1.handle,WM_CHAR,13,0);
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
Editor: TRichEdit;
Edit1: TEdit;
function UpdateCursorPos:integer;
procedure EditorKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses RichEdit;resourcestring
sColRowInfo = '%3d';
{$R *.dfm}function Tform1.UpdateCursorPos:integer;
var
CharPos: TPoint;
begin
CharPos.Y := SendMessage(Editor.Handle, EM_EXLINEFROMCHAR, 0,
Editor.SelStart);
CharPos.X := (Editor.SelStart -
SendMessage(Editor.Handle, EM_LINEINDEX, CharPos.Y, 0));
Inc(CharPos.Y);
Inc(CharPos.X);
result:= strtoint(Format(sColRowInfo,[CharPos.X]));
end;
procedure TForm1.EditorKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if updatecursorpos>10 then
sendmessage(Editor.handle,WM_CHAR,13,0)
else
//用于显示所在地方
edit1.Text:=inttostr(UpdateCursorPos);
end;
{没考虑插入时的换行}
end.
Form1: TForm1; const WORD_WIDE=10;//文本的宽度,在此设为10字换行。implementation{$R *.dfm}procedure TForm1.RichEdit1Change(Sender: TObject);
var i,j,K:longint;
begin
i:= SendMessage(richedit1.Handle,EM_LINEFROMCHAR,richedit1.SelStart,0);
j:=SendMessage(richedit1.Handle,EM_LINEINDEX,i,0);
k:=length(richedit1.Lines[i]);
if k-WORD_WIDE>=0 THEN
sendmessage(richedit1.handle,WM_CHAR,13,0);end;
比楼上的简单多了吧!!!