delphi 控制滚动条


本文整理自网络,侵删。

 

DELPHI的发送消息

function TControl.Perform(
        Msg: Cardinal;
        WParam: WPARAM;
        LParam: LPARAM
): LRESULT;

Memo1.Perform(WM_HSCROLL, SB_LEFT, 0); 

 

水平滚动条

水平滚动条消息    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 (thumbin the specified 
scroll barThe current position is a relative value that depends on the current scrolling range
For exampleif the scrolling range is 0 through 100 and the scroll box is in the middle of the 
barthe current position is 50. 
int GetScrollPos(          
    HWND hWnd,
    int nBar
);
var
  hvInteger;
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_STYLEand WS_VSCROLL) > 0 then ShowMessage('Vertical scrollbar is visible!'); if (GetWindowlong(Memo1.Handle, GWL_STYLEand WS_HSCROLL) > 0 then ShowMessage('Horizontal scrollbar is visible!'); end;

相关阅读 >>

Delphi 判断字符串是否相同

Delphi 关闭rtti反射机制减少exe文件尺寸

Delphi 调用ie隐藏的命令

Delphi 中判断一个字符是中文的方法

dll与exe之间的恩爱情仇

Delphi 比较两个日期是否大于n天

Delphi把一个字符串中的某个子串,用另一个子串去替换

Delphi application.messagebox 详解

Delphi vclzip压缩文件夹

Delphi调用createprocess创建进程

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    暂无评论...