Einzelnen Beitrag anzeigen

Benutzerbild von anse
anse

Registriert seit: 30. Okt 2006
Ort: Neuenkirchen
196 Beiträge
 
Delphi 11 Alexandria
 
#4

Re: Mausrad für nicht fokussierte Komponente

  Alt 27. Dez 2009, 07:20
Mit VT.OffsetY klappts:
Delphi-Quellcode:
procedure TMainForm.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
  var Handled: Boolean);
var
  Control: TWinControl;
  VT: TBaseVirtualTree;
begin
  // TODO: Does not work when a SynMemo has focus, probably related to the broken solution of this issue:
  // [url]http://sourceforge.net/tracker/index.php?func=detail&aid=1574059&group_id=3221&atid=103221[/url]
  Control := FindVCLWindow(MousePos);
  if (Control is TBaseVirtualTree) and (not Control.Focused) and PtInRect(Control.ClientRect, Control.ScreenToClient(MousePos)) then begin
    VT := Control as TBaseVirtualTree;
    VT.OffsetY := VT.OffsetY + (WheelDelta div 2); // Don't know why, but WheelDelta is twice as big as it normally appears
    VT.UpdateScrollBars(True);
    Handled := True;
  end else
    Handled := False;
end;
Ansgar Becker
https://www.heidisql.com
Wenn du loslässt, hast du zwei Hände frei.
  Mit Zitat antworten Zitat