AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Fokus wird nicht gesetzt

Ein Thema von Alfonso · begonnen am 22. Apr 2012 · letzter Beitrag vom 22. Apr 2012
 
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.590 Beiträge
 
Delphi 12 Athens
 
#7

AW: Fokus wird nicht gesetzt

  Alt 22. Apr 2012, 19:37
Ein Bug?
Es gibt ja einmal den Fokus, welchen Delphi glaubt gesetzt zu haben und dann noch den Fokus, welcher beim WinControl wirklich aktiv ist.

Hab selber grade mit sowas zu kämpfen
http://www.delphipraxis.net/167825-p...gabefokus.html


Was sagt diese Variante?
Delphi-Quellcode:
procedure TForm4.Timer1Timer(Sender: TObject);
var
  S: string;
  H: HWND;
  C: TControl;
  B: array[0..MAX_PATH] of Char;
  i: Integer;
begin
  if Application.Active then S := 'Active else S := 'Inactive ';
  if Assigned(Screen.ActiveCustomForm) then
    S := S + Screen.ActiveCustomForm.ClassName + '.' + Screen.ActiveCustomForm.Name + ' ';
  if Assigned(Screen.ActiveForm) and Assigned(Screen.ActiveForm.ActiveMDIChild) then
    S := S + 'MDI:' + Screen.ActiveForm.ActiveMDIChild.ClassName + '.' + Screen.ActiveForm.ActiveMDIChild.Name + ' ';
  if Assigned(Screen.ActiveControl) then
    S := S + Screen.ActiveControl.ClassName + '.' + Screen.ActiveControl.Name + ' ';
  H := GetActiveWindow;
  C := FindControl(H);
  if not Assigned(C) then begin
    GetClassName(H, @B, MAX_PATH);
    S := S + '(' + B + ' ';
  end else
    S := S + '(' + C.ClassName + '.' + C.Name + ' ';
  H := GetFocus;
  C := FindControl(H);
  if not Assigned(C) then begin
    GetClassName(H, @B, MAX_PATH);
    S := S + B + ') ';
  end else
    S := S + C.ClassName + '.' + C.Name + ') ';

  Application.Title := S;
  for i := 0 to Screen.CustomFormCount - 1 do
    Screen.CustomForms[i].Caption := S;
end;

[add]
Statt deinem Hack würde ich es mal so probieren (in dem Timer)
Delphi-Quellcode:
if Application.Active then
  SetActive(Screen.ActiveControl.Handle);
bzw.
Delphi-Quellcode:
if Application.Active and (Screen.ActiveControl.Handle <> GetActive) then
  SetActive(Screen.ActiveControl.Handle);
Ein Therapeut entspricht 1024 Gigapeut.

Geändert von himitsu (22. Apr 2012 um 19:41 Uhr)
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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 01:50 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