控制滚动条的消息

水平滚动条消息    WM_HSCROLL                                         

SendMessage(Memo1.Handle, WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, 50), 0);  //滚动至此               

SendMessage(Memo1.Handle, WM_HSCROLL, SB_LEFT, 0);                           //左边缘           

SendMessage(Memo1.Handle, WM_HSCROLL, SB_RIGHT, 0);                          //右边缘               

SendMessage(Memo1.Handle, WM_HSCROLL, SB_PAGELEFT, 0);                       //向左翻页               

SendMessage(Memo1.Handle, WM_HSCROLL, SB_PAGERIGHT, 0);                      //向右翻页           

SendMessage(Memo1.Handle, WM_HSCROLL, SB_LINELEFT, 0);                       //向左滚动           

SendMessage(Memo1.Handle, WM_HSCROLL, SB_LINERIGHT, 0);                      //向右滚动 垂直滚动条消息    WM_VSCROLL                                        
SendMessage(Memo1.Handle, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, 50), 0); //滚动至此 50为位置  滚动到指定行号       
SendMessage(Memo1.Handle, WM_VSCROLL, SB_TOP, 0);                           //顶部            
SendMessage(Memo1.Handle, WM_VSCROLL, SB_BOTTOM, 0);                        //底部            
SendMessage(Memo1.Handle, WM_VSCROLL, SB_PAGEUP, 0);                        //向上翻页        
SendMessage(Memo1.Handle, WM_VSCROLL, SB_PAGEDOWN, 0);                      //向下翻页        
SendMessage(Memo1.Handle, WM_VSCROLL, SB_LINEUP, 0);                        //向上滚动        
SendMessage(Memo1.Handle, WM_VSCROLL, SB_LINEDOWN, 0);                      //向下滚动
获得滚动条的位置
The GetScrollPos function retrieves the current position of the scroll box (thumb) in the specified 
scroll bar. The current position is a relative value that depends on the current scrolling range. 
For example, if the scrolling range is 0 through 100 and the scroll box is in the middle of the 
bar, the current position is 50. 
int GetScrollPos(          
    HWND hWnd,
    int nBar
);
var
  h, v: Integer;
begin
  h := GetScrollPos(Memo1.Handle, SB_HORZ);
  v := GetScrollPos(Memo1.Handle, SB_VERT);
  Caption := Format('水平数值=%d 垂直数值=%d', [h, v]);
end;
显示和隐藏滚动条
//隐藏MEMO水平滚动条
ShowScrollBar(Memo1.Handle,SB_HORZ,false);
//隐藏MEMO垂直滚动条
ShowScrollBar(Memo1.Handle,SB_VERT,false);

 判断 滚动条是否出现
procedure TForm1.Button1Click(Sender: TObject);

 begin    

    if (GetWindowlong(Memo1.Handle, GWL_STYLE) and WS_VSCROLL) > 0 then 

          ShowMessage('Vertical scrollbar is visible!'); 

   if (GetWindowlong(Memo1.Handle, GWL_STYLE) and WS_HSCROLL) > 0 then    

         ShowMessage('Horizontal scrollbar is visible!');

 end; 

转载于:https://www.cnblogs.com/deluxtx/p/9372184.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值