Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

is scrollbar enabled.

I have a TRichEdit with the ScrollBars property set to ssBoth, but i need a way to check if the scroll bar is enabled.
0
heretoread
Asked:
heretoread
  • 2
1 Solution
 
wildzeroCommented:
By enabled you mean, is showing up? (ie the user has lots of text in the box?)
0
 
heretoreadAuthor Commented:
yes, is it currently active.

i need this because if a user resizes the form the richedit is also resized to stay in proportion, but if the scroll bar is active and the form was resized quick, GetScrollPos() will not always return 0.

so my aim is to make a function like

function ScrollPos:Integer;
begin
  if Active then
    //Scrollpos result
  else
    Result:= 0;
end;
0
 
pcsentinelCommented:
try this

*********************UNIT CODE*********************
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
      lInfo: TScrollBarInfo;
  lh: HWnd;
begin
   FillChar(lInfo, Sizeof(lInfo), 0);
   lInfo.cbSize := Sizeof(lInfo);

      GetScrollBarInfo(richedit1.handle, OBJID_VSCROLL,
        lInfo);

  if ((lInfo.rgstate[0] and STATE_SYSTEM_INVISIBLE) = STATE_SYSTEM_INVISIBLE) then
        label1.caption:='Vert Scroll Bar Not visible'
      else
        label1.caption:='Vert Scroll Bar Visible'

end;

end.

**************FORM CODE**********************
object Form1: TForm1
  Left = 23
  Top = 29
  Width = 307
  Height = 217
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 132
    Top = 140
    Width = 32
    Height = 13
    Caption = 'Label1'
  end
  object RichEdit1: TRichEdit
    Left = 28
    Top = 32
    Width = 229
    Height = 89
    Lines.Strings = (
      'RichEdit1')
    ScrollBars = ssBoth
    TabOrder = 0
  end
  object Button1: TButton
    Left = 24
    Top = 132
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
end

*************************************

regards
0
 
heretoreadAuthor Commented:
Thanks, That was half what i needed, tho i changed STATE_SYSTEM_INVISIBLE to STATE_SYSTEM_UNAVAILABLE.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now