发送EM_LINESCROLL消息给Memo
EM_LINESCROLL消息可以滚动多行的编辑空间Memo和richEdit
要发送这个消息,使用以下参数调用SendMessage()。
SendMessage(
hWnd:HWND; // handle to destination window
EM_LINESCROLL; //message to send
wParam:Integer;// horizontal scroll increment(垂直滚动)
lParam:Integer // vertical scroll increment(水平滚动)
)
参数
wParam
TMemo: Specifies the number of characters to scroll horizontally.
Rich edit controls: This parameter is not used; it must be zero.
lParam
Specifies the number of lines to scroll vertically.
Return Values
If the message is sent to a multiline edit control, the return value is TRUE.
If the message is sent to a single-line edit control, the return value is FALSE.
发送EM_LINESCROLL消息给Memo
EM_LINESCROLL消息可以滚动多行的编辑空间Memo和richEdit
要发送这个消息,使用以下参数调用SendMessage()。
SendMessage(
hWnd:HWND; // handle to destination window
EM_LINESCROLL; //message to send
wParam:Integer;// horizontal scroll increment(垂直滚动)
lParam:Integer // vertical scroll increment(水平滚动)
)
参数
wParam
TMemo: Specifies the number of characters to scroll horizontally.
Rich edit controls: This parameter is not used; it must be zero.
lParam
Specifies the number of lines to scroll vertically.
Return Values
If the message is sent to a multiline edit control, the return value is TRUE.
If the message is sent to a single-line edit control, the return value is FALSE.
发送EM_LINESCROLL消息给Memo
EM_LINESCROLL消息可以滚动多行的编辑空间Memo和richEdit
要发送这个消息,使用以下参数调用SendMessage()。
SendMessage(
hWnd:HWND; // handle to destination window
EM_LINESCROLL; //message to send
wParam:Integer;// horizontal scroll increment(垂直滚动)
lParam:Integer // vertical scroll increment(水平滚动)
)
参数
wParam
TMemo: Specifies the number of characters to scroll horizontally.
Rich edit controls: This parameter is not used; it must be zero.
lParam
Specifies the number of lines to scroll vertically.
Return Values
If the message is sent to a multiline edit control, the return value is TRUE.
If the message is sent to a single-line edit control, the return value is FALSE.
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
begin
for i:=0 to 10 do begin
self.Memo1.Lines.Add('aaaaaaaaaaaaaaaaaaaaaaaaa') ;
self.Memo1.Lines.Add('bbbbbbbbbbbbbbbbbbbbbbbbb')
end;
self.Memo1.Enabled:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
//getscrollpos(self.Memo1.Handle,SB_VERT));
i:=0 ;
while i<=self.Memo1.Lines.Count-1 do begin
setscrollpos(self.Memo1.Handle,SB_VERT,i,false);
if i=self.Memo1.Lines.Count-1 then i:=0;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
aa:TRect;
i,j:integer;
begin
aa.Left:=self.Memo1.Left;aa.Right:=self.Memo1.Left+self.Memo1.Width;
aa.Top:=self.Memo1.Top;aa.Bottom:=self.Memo1.Top+self.Memo1.Height;
i:=0 ;j:=-1;
while i<=self.Memo1.Height-1 do begin
setscrollpos(self.Memo1.Handle,SB_VERT,j,true);
ScrollWindow(self.Memo1.Handle,0,-1,nil,nil);
UpdateWindow(self.Memo1.Handle);
// self.Memo1.Refresh;
// self.Memo1.Realign;
if i=self.Memo1.Height-1 then begin
i:=0;
j:=(-1)*j;
end;
sleep(500);
application.ProcessMessages;
end;