unit scrolllist;
interface
uses
Messages, Classes, StdCtrls;
type
ListScrollBox =
class(TListBox)
private
FOnScroll: TScrollEvent;
procedure WMMouseWheel(
var Message: TWMMOUSEWHEEL);
message WM_MOUSEWHEEL;
procedure WMHScroll(
var Message: TWMHScroll);
message WM_HSCROLL;
procedure WMVScroll(
var Message: TWMVScroll);
message WM_VSCROLL;
published
property OnScroll: TScrollEvent
read FOnSCroll
write FOnScroll;
end;
procedure Register;
implementation
uses Controls;
procedure ListScrollBox.WMMouseWheel(
var Message: TWMMOUSEWHEEL);
begin
if Message.WheelDelta > 0
then
Perform(WM_VSCROLL, SB_LINEUP, 0) ---> hier bekomme ich eine Fehlermeldung wegen SB_LINEUP
else
Perform(WM_VSCROLL, SB_LINEDOWN, 0); ---> hier bekomme ich eine Fehlermeldung wegen SB_LINEDOWN
Message.Result := 0;
end;
procedure ListScrollBox.WMHScroll(
var Message: TWMHScroll);
var
ScrollPos: Integer;
begin
inherited;
ScrollPos :=
Message.Pos;
if Assigned(FOnScroll)
then
if TScrollCode(
Message.ScrollCode)
in [scLineUp, scLineDown,
scPageUp, scPageDown, scPosition, scTop, scBottom]
then
FOnScroll(Self, TScrollCode(
Message.ScrollCode), ScrollPos);
end;
procedure ListScrollBox.WMVScroll(
var Message: TWMVScroll);
var
ScrollPos: Integer;
begin
inherited;
ScrollPos :=
Message.Pos;
if Assigned(FOnScroll)
then
if TScrollCode(
Message.ScrollCode)
in [scLineUp, scLineDown,
scPageUp, scPageDown, scPosition, scTop, scBottom]
then
FOnScroll(Self, TScrollCode(
Message.ScrollCode), ScrollPos);
end;
procedure Register;
begin
RegisterComponents('
Samples',[ListScrollBox]);
end;
end.