AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

SetFocus ohne ScrollInView

Ein Thema von stahli · begonnen am 1. Dez 2008 · letzter Beitrag vom 9. Dez 2008
Antwort Antwort
Benutzerbild von stahli
stahli

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

SetFocus ohne ScrollInView

  Alt 1. Dez 2008, 22:25
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
  Mit Zitat antworten Zitat
Benutzerbild von stahli
stahli

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

Re: SetFocus ohne ScrollInView

  Alt 4. Dez 2008, 09:38
*push*
  Mit Zitat antworten Zitat
Benutzerbild von stahli
stahli

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

Re: SetFocus ohne ScrollInView

  Alt 9. Dez 2008, 15:29
So, durch Überschreiben der virtuellen Methode AutoScrollInView ist es realisierbar.
"BlockAutoScrollInView" ist eine neue Variable, die ich nach Bedarf selbst definieren kann.

Delphi-Quellcode:
procedure TDesignerBox.AutoScrollInView(AControl: TControl);
begin
  if not BlockAutoScrollInView then
    inherited;
end;
stahli
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz