如题

解决方案 »

  1.   

    Harryfin,你这个滚动条指的是哪的,是单独的,还是form尺寸不够时出现的滚动条
      

  2.   

    function HasScroll(hWND:HWND):Boolean;
    var ff:TForm;
    begin
      Result := false;
      if IsVCLControl(hWND) then
      begin
        ff := FindControl(hWND) as TForm;
        if (ff <> nil) and ff.ScrollInView(ff) then
          Result := true;
      end;
    end;不敢肯定是否可用。
    你试试看?
      

  3.   

    自带的,如果是TScrollBar的画就肯定无能为力了ps. 我这个窗体说的是广义的windows窗体
      

  4.   

    所以转型成TForm的话应该就不符合需求了
      

  5.   

    随便写个,不完整。有一定参考价值var
    h,hc:HWND;
    begin
    h:=findwindow('Tform1',nil);
    hc:=Findwindowex(h,nil,'Tscroll',nil);
    if hc <>0 then
     begin
      //有滚动条
     end;
    end;
    提前用spy++看看结构是不是Tscroll。
      

  6.   


    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        Memo2: TMemo;
        ListBox1: TListBox;
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    function ScrollBarVisible(H: THandle; Code: Word): Boolean;
    var
      Style: Longint;
    begin
      Style := WS_HSCROLL;
      if Code = SB_VERT then Style := WS_VSCROLL;
      Result := GetWindowLong(H, GWL_STYLE) and Style <> 0;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      H: THandle;
    begin
      H := ListBox1.Handle;
      if H<>0 then Memo2.Lines.Add('ok');
      if ScrollBarVisible(H, SB_VERT) then
        Memo2.Lines.Add('VSCROLL');
      if ScrollBarVisible(H, SB_HORZ) then
        Memo2.Lines.Add('HSCROLL');
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
      I: integer;
    begin
      for I:=100 to 1000 do
        Listbox1.Items.Add('数据项数据项第'+IntToStr(i));
    end;end.对记事本什么的无效。对一般的Form ListBox Memo标准控件还可以。
      

  7.   

    我的意思是WINDOWS的标准滚动条而已,上面已经说过了。
      

  8.   

    这个滚动条总是在哪个控件之上的吧?要找到共同点。可以参考一下,TScrollingWinControl。(TForm的基类)
      

  9.   

    WS_VSCROLL  竖直滚动条
    WS_HSCROLL 水平滚动条
    var
      dwHandle:THandle;
      iResult:Integer;
    begin
      dwHandle:=$00A40D6A;//窗口句柄
      iResult:=GetWindowLong(dwHandle,GWL_STYLE);
      if ((iResult and WS_VSCROLL )>0 ) or ( (iResult and WS_HSCROLL )>0)  then
      begin
        ShowMessage('');
      end;
      

  10.   

    能根据scrollwidth或scrollheight值来判断有无滚动条
      

  11.   

    TScrollingWinControl。(TForm的基类)
      

  12.   

    可根據FORM窗口句柄去找
    WS_VSCROLL 竖直滚动条
    WS_HSCROLL 水平滚动条