2010. január 2., szombat

Check if scrollbars are present in a TListView


Problem/Question/Abstract:

Is there a way to determine if the scrollbars are present with a TListView component? If so, is it possible to be specific enough to determine which one is present, i.e vertical scroll or horizontal scroll?

Answer:

Yes to both:

{Function WindowScrollbars

Parameters:
Window handle of control or window to check.

Returns:
The TScrollstyle describing the current scrollbar configuration, either ssNone, ssHorizontal, ssVertical, ssBoth.

Description:
Checks the WS_VSCROLL and WS_HSCROLL style bits of the window style.

Error Conditions: none
Created: 21.10.99 by P. Below}

function WindowScrollbars(wnd: HWND): TScrollStyle;
var
  styleflags: DWORD;
begin
  styleflags := GetWindowLong(wnd, GWL_STYLE) and (WS_VSCROLL or WS_HSCROLL);
  case styleflags of
    0: Result := ssNone;
    WS_VSCROLL: Result := ssVertical;
    WS_HSCROLL: Result := ssHorizontal;
  else
    Result := ssBoth;
  end;
end;

Call with listview.handle as parameter.

Nincsenek megjegyzések:

Megjegyzés küldése