![]() |
SetFocus ohne ScrollInView
Hallo alle,
meinen Controls in einer TscrollBox weise ich den Focus zu. Dadurch wird ScrollInView ausgeführt und das entsprechende Control komplett in den sichtbaren Bereich verschoben, was ich (unter bestimmten Umständen) verhindern möchte.
Delphi-Quellcode:
procedure TWinControl.SetFocus;
var Parent: TCustomForm; begin Parent := GetParentForm(Self); if Parent <> nil then Parent.FocusControl(Self) // <=== else if ParentWindow <> 0 then Windows.SetFocus(Handle) else ValidParentForm(Self); end; procedure TCustomForm.FocusControl(Control: TWinControl); var WasActive: Boolean; begin WasActive := FActive; SetActiveControl(Control); // <=== if not WasActive then SetFocus; end; procedure TCustomForm.SetActiveControl(Control: TWinControl); begin if FActiveControl <> Control then begin if not ((Control = nil) or (csDesigning in ComponentState) or ((Control <> Self) and (GetRealParentForm(Control) = Self) and ((csLoading in ComponentState) or Control.CanFocus))) then raise EInvalidOperation.Create(SCannotFocus); FActiveControl := Control; if not (csLoading in ComponentState) then begin if FActive then SetWindowFocus; ActiveChanged; end; end; end; Kann jemand sagen, wie ich das automatische ScrollInView verhindern kann und die Controls trotzdem den Fokus erhalten? Die letzten beiden Methoden sind nicht virtual. Danke Stahli |
Re: SetFocus ohne ScrollInView
*push*
|
Re: SetFocus ohne ScrollInView
So, durch Überschreiben der virtuellen Methode AutoScrollInView ist es realisierbar.
"BlockAutoScrollInView" ist eine neue Variable, die ich nach Bedarf selbst definieren kann.
Delphi-Quellcode:
stahli
procedure TDesignerBox.AutoScrollInView(AControl: TControl);
begin if not BlockAutoScrollInView then inherited; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:51 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz