Einzelnen Beitrag anzeigen

Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.337 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: Mausrad, ScrollBox und PageControl

  Alt 7. Nov 2012, 19:50
Ich habe jetzt nicht ganz genau verstanden welches Problem aktuell noch besteht, vielleicht gibt das Beispiel ggf. eine Anregung...

Delphi-Quellcode:
procedure TFormTest.MessageEvent(var Msg: TMsg; var Handled: Boolean);
var
  H: HWND;
  C: TControl;
  WC: TWinControl;
  I: Integer;

  function GetParentScrollBox(WC: TWinControl): TWinControl;
  begin
    Result := WC;
    if (not(WC is TScrollBox)) and (WC.Parent <> nil) then
      Result := GetParentScrollBox(WC.Parent);
  end;

begin
  if ((Msg.Message = WM_MOUSEWHEEL) or (Msg.Message = WM_MOUSEHWHEEL)) and (Msg.wParam and MK_CONTROL = 0) then
    begin
      H := WindowFromPoint(Msg.Pt);
      C := FindControl(H);
      if C is TWinControl then
        begin
          WC := GetParentScrollBox(C as TWinControl);
          if WC <> nil then
            begin
              for I := 1 to Mouse.WheelScrollLines do
                WC.Perform(CM_MOUSEWHEEL, Msg.wParam, Msg.lParam); // Msg.Message funktioniert nicht
              H := 0;
            end;
        end;
      if (H = 0) or ((Msg.HWND <> H) and (GetWindowThreadProcessId(H, nil) <> GetCurrentThreadId)) then
        begin
          Msg.HWND := 0;
          Msg.Message := WM_NULL;
          Handled := True;
        end
      else
        Msg.HWND := H;
    end
end;
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat