Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Buttons und Labels verschwinden (https://www.delphipraxis.net/107282-buttons-und-labels-verschwinden.html)

Mike_on_Tour 25. Jan 2008 08:59


Buttons und Labels verschwinden
 
Hallo,

ich habe folgendes Problem: Unter Windows Vista verschwinden bei meinem Programm zur Laufzeit einige Labels und Buttons, wenn ich die AltGr-Taste drücke. Unter WindowsXP bleiben die Labels und Buttons sichtbar und nutzbar. Im Programm werden keine Sondertasten ausgewertet. Da auch nicht alle Labels und Buttons betroffen sind, finde ich keinen Ansatz für eine Fehlersuche. Wer hat schon mal das gleiche Problem gehabt bzw. wer hat einen Tip ?

Mike

Bernhard Geyer 25. Jan 2008 09:15

Re: Buttons und Labels verschwinden
 
Auf dn.codegear.com wurde auf dieses Verhalten bei AFAIK Delphi 2007 gemeldet und wurde AFAIK mit dem letzten Update behoben.

Mike_on_Tour 25. Jan 2008 09:23

Re: Buttons und Labels verschwinden
 
Und wer lesen kann, ist klar im Vorteil.

Es geht um Delphi 2005 Pro.

Bernhard Geyer 25. Jan 2008 09:44

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von Mike_on_Tour
Und wer lesen kann, ist klar im Vorteil.

Es geht um Delphi 2005 Pro.

Ja und? Evtl. gibt es dieses Problem auch bei D2005 aber wurde nicht erkannt da man ja zur damaligen Zeit noch keine Vista zur verfügung hatte. Und wieso sollte ein Fehler in der VCL behoben werden wenn er in den damals verfürbaren Windows-Versionen nicht auftritt?

Rakshasa 25. Jan 2008 09:51

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von Bernhard Geyer
Ja und? Evtl. gibt es dieses Problem auch bei D2005 aber wurde nicht erkannt da man ja zur damaligen Zeit noch keine Vista zur verfügung hatte.

So ist es :-) ...der Fehler wurde übrigens beim Update #1 für Delphi2007 behoben.

Mike_on_Tour 25. Jan 2008 10:18

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von Bernhard Geyer
Ja und? Evtl. gibt es dieses Problem auch bei D2005 aber wurde nicht erkannt da man ja zur damaligen Zeit noch keine Vista zur verfügung hatte. Und wieso sollte ein Fehler in der VCL behoben werden wenn er in den damals verfürbaren Windows-Versionen nicht auftritt?

Es ist ja schön, wenn es ein Bug ist, der in Delphi 2007 behoben ist. Ich kann aber nicht einfach mal schnell meine Delphi-Version ändern. Und es gibt sicher eine Menge D2005-Programme, die unter Windows Vista laufen. Und da das auch noch eine Zeit lang so sein wird, macht ein Update der VCL schon Sinn. Aber da verdient man ja nichts dran.

Mike

Bernhard Geyer 25. Jan 2008 10:21

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von Mike_on_Tour
Zitat:

Zitat von Bernhard Geyer
Ja und? Evtl. gibt es dieses Problem auch bei D2005 aber wurde nicht erkannt da man ja zur damaligen Zeit noch keine Vista zur verfügung hatte. Und wieso sollte ein Fehler in der VCL behoben werden wenn er in den damals verfürbaren Windows-Versionen nicht auftritt?

Es ist ja schön, wenn es ein Bug ist, der in Delphi 2007 behoben ist. Ich kann aber nicht einfach mal schnell meine Delphi-Version ändern.

Du mußt nicht umbedingt wechseln. Falls dir D2005 und D2007 zur verfügung steht kannst du u.U. selbst im Sourcecode herausfinden welche Code nicht passt und deine D2005-VCL selbst patchen. ist halt nicht gerade einfach. Evtl. findest du den DN.Codegear-Eintrag und dort wird auf dem Codebereich hingewiesen.

RavenIV 25. Jan 2008 10:24

Re: Buttons und Labels verschwinden
 
Das D2005 soll ja so buggy sein, dass man da nicht damit arbeiten kann.
Hab ich gehört, selber gesehen hab ich's nicht.

Und dann hat CodeGear eben irgendwann aufgegeben mit dem Reparieren.
Frag doch mal direkt bei CodeGear an, was Du da machen kannst.
Vielleicht bekommst DU ein günstiges Upgrade zu D2007.

Oder Du schaust beim CodeGear-Support, ob's Abhilfe gibt.
Du bist sicher nicht der Erste, dem dieser Fehler augefallen ist.

Mike_on_Tour 25. Jan 2008 10:35

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von Bernhard Geyer
Falls dir D2005 und D2007 zur verfügung steht kannst du u.U. selbst im Sourcecode herausfinden welche Code nicht passt und deine D2005-VCL selbst patchen.

... und mache nebenbei gleich noch die Bugs in Windows raus. :-D Da muß es eine andere Lösung geben.

Mike

Mike_on_Tour 25. Jan 2008 10:39

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von RavenIV
Das D2005 soll ja so buggy sein, dass man da nicht damit arbeiten kann.
Hab ich gehört, selber gesehen hab ich's nicht.

Nach dem Einspielen der drei verfügbaren Updates für Delphi 2005 läuft das System auch nach über 6 Monaten noch stabil.
Hab ich gesehen, nicht gehört. :zwinker:

RavenIV 25. Jan 2008 10:54

Re: Buttons und Labels verschwinden
 
Und bei drei (!) Update für D2005 haben sie es nicht geschafft, auch diesen Fehler zu beseitigen?

OK, bei D2007 gibt's ja auch schon etliche Update und es hat immernoch etliche Fehler und Ungereimtheiten.

Bernhard Geyer 25. Jan 2008 10:56

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von Mike_on_Tour
Da muß es eine andere Lösung geben.

Ich glaube nicht das Codegear noch Patches für D2005 herausbringt.

RavenIV 25. Jan 2008 10:59

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von Bernhard Geyer
Ich glaube nicht das Codegear noch Patches für D2005 herausbringt.

Wir haben doch hier in der DP so einen Typen, der das BDS wie seine Westentasche kennt und auch das DelphiSpeedup (und manches andere) entwickelt hat.
Vielleicht kann man ihn dazu überreden, einen Patch für dieses Problem zu bauen?
:duck:

SirThornberry 25. Jan 2008 11:03

Re: Buttons und Labels verschwinden
 
naja, man sollte nicht von anderen Initiative erwarten wenn man selbst nicht bereit ist einfach mal durchzusteppen wo die alt-GR-Taste abgefangen wird und was da passiert.

Bernhard Geyer 25. Jan 2008 11:13

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von RavenIV
..., der das BDS wie seine Westentasche kennt und auch das DelphiSpeedup (und manches andere) entwickelt hat.
Vielleicht kann man ihn dazu überreden, einen Patch für dieses Problem zu bauen?

Ist ja ein VCL-Problem und kein IDE-Problem. Und da heißt es Sourcecode in der VCL anpassen.

RavenIV 25. Jan 2008 11:22

Re: Buttons und Labels verschwinden
 
Zitat:

Zitat von Bernhard Geyer
Ist ja ein VCL-Problem und kein IDE-Problem. Und da heißt es Sourcecode in der VCL anpassen.

Es gibt ja auch noch den Andreas Hausladen, der kennt sich mit der VCL gut aus.
Sollte man ihn mal anlabern?
http://andy.jgknet.de/

Und ich will niemandem Arbeit aufladen, nur weil ich sie nicht selber machen will.

Sven Bobrowski 25. Jan 2008 12:36

Re: Buttons und Labels verschwinden
 
http://qc.codegear.com/wc/qcmain.aspx?d=37403

Delphi-Quellcode:
{
Copyright © Norstedts Juridik AB
Made by Per-Erik Andersson, inspired by J Hamblin - Qtools Software.
Author grants unrestricted use of this software code.
All use is on your own risk.

J Hamblin has made a component TjhALTBugFix to solve a problem in Vista.
It can be downloaded from CodeGear Quality centre here:
[url]http://qc.codegear.com/wc/qcmain.aspx?d=37403[/url]
Below is the text J Hamblin wrote that describes the problem:

** Quote **************
There seems to be a problem with THEMES support in Delphi, in which
TButton, TCheckBox, TRadioButton and TStaticText standard controls
vanish in VISTA when the ALT key is pressed. (only TStaticText vanishes in XP).
If the OS is set to default, pressing the ALT key in XP and Vista has the
behavior of displaying the underline under the accelerator keys.

The mentioned controls vanish the first time ALT is pressed. They can be
restored by repainting the control in code. Once restored, they are not
affected by subsequent ALT key presses -- unless a pagecontrol on the form
changes to a new tabsheet, then all affected controls, both on the tabsheet
and on the form, will vanish on next ALT press. Due to the pagecontrol issue
there is no way to set a flag to do the repaint op only once. In MDI applications,
an ALT key press has the same affect on all child forms at the same time.
** End quote **************

The TjhALTBugFix needs to be put on each form in the application which
is a problem in many large applications. Therefore I made this component
that can be dropped on the main form and then handles all delphi forms
that are created.

The component works like this: In Idle it goes through the list of existing
Delphi forms in TScreen. When a new form is found, its WindowProc is replaced
with a hook that listens for the event WM_UPDATEUISTATE which is the
message triggering the error.
When a form has got an WM_UPDATEUISTATE it gets a flag the says it needs to
be redrawn. The next time the application enters Idle a repaint is made,
depending on the property RepaintAll. If it is true all TWinControls on the
form gets a repaint. If its false only the component that probably needs a
repaint is repainted (that code mady by J Hamblin).
The "repaint all" is an precausion for third part components that might behave in
the same way. RepaintAll is default true.
Note that this component is only active in Vista. If you want it to
handle the TStaticText in XP you have to remove the VistaWithTheme check
in TVistaAltFix.Create.

Usage:
If you want to use this as an component you have to install it into the Delphi IDE.
If you don't want to do that just add this code in your main form OnCreate:

procedure TMainForm.FormCreate(Sender: TObject);
begin
  TVistaAltFix.Create(Self);
end;

}

unit VistaAltFixUnit;

interface
uses
  ExtCtrls, Classes, Contnrs, AppEvnts;

type
  TVistaAltFix = class(TComponent)
  private
    FList: TObjectList;
    FApplicationEvents: TApplicationEvents;
    FRepaintAll: Boolean;
    procedure ApplicationEventsIdle(Sender: TObject; var Done: Boolean);
    function VistaWithTheme: Boolean;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property RepaintAll: Boolean read FRepaintAll write FRepaintAll default True;
  end;

procedure Register;

implementation
uses
  Forms, Windows, Messages, Buttons, ComCtrls, Controls, StdCtrls, Themes;

type
  TFormObj = class(TObject)
  private
    procedure WndProc(var Message: TMessage);
  public
    Form: TForm;
    OrgProc: TWndMethod;
    Used: Boolean;
    NeedRepaint: Boolean;
    RepaintAll: Boolean;
    constructor Create(aForm: TForm; aRepaintAll: Boolean);
    procedure DoRepaint;
  end;

procedure Register;
begin
  RegisterComponents('MEP', [TVistaAltFix]);
end;

{ TVistaAltFix }

procedure TVistaAltFix.ApplicationEventsIdle(Sender: TObject;
  var Done: Boolean);
var
  I: Integer;
  J: Integer;
  TestForm: TForm;
begin
  // Initialize
  for I := 0 to FList.Count - 1 do
    TFormObj(FList[i]).Used := False;

  // Check for new forms
  for I := 0 to Screen.FormCount - 1 do
  begin
    TestForm := Screen.Forms[i];
    for J := 0 to FList.Count - 1 do
    begin
      if TFormObj(FList[J]).Form = TestForm then
      begin
        TFormObj(FList[J]).Used := True;
        TestForm := nil;
        Break;
      end;
    end;
    if Assigned(TestForm) then
      FList.Add(TFormObj.Create(TestForm, RepaintAll));
  end;

  // Remove destroyed forms, repaint others if needed.
  for I := FList.Count - 1 downto 0 do
  begin
    if not TFormObj(FList[i]).Used then
      FList.Delete(i)
    else
      TFormObj(FList[i]).DoRepaint;
  end;
end;

constructor TVistaAltFix.Create(AOwner: TComponent);
begin
  inherited;
  FRepaintAll := True;
  if VistaWithTheme and not (csDesigning in ComponentState) then
  begin
    FList := TObjectList.Create;
    FApplicationEvents := TApplicationEvents.Create(nil);
    FApplicationEvents.OnIdle := ApplicationEventsIdle;
  end;
end;

destructor TVistaAltFix.Destroy;
begin
  FApplicationEvents.Free;
  FList.Free;
  inherited;
end;

function TVistaAltFix.VistaWithTheme: Boolean;
//var
//  OSVersionInfo: TOSVersionInfo;
begin
  Result := ThemeServices.ThemesEnabled;
{
  OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo);
  if GetVersionEx(OSVersionInfo) and
     (OSVersionInfo.dwMajorVersion >= 6) and
     ThemeServices.ThemesEnabled then
    Result := True
  else
    Result := False;}
end;

{ TFormObj }

constructor TFormObj.Create(aForm: TForm; aRepaintAll: Boolean);
begin
  inherited Create;
  Form := aForm;
  RepaintAll := aRepaintAll;
  Used := True;
  OrgProc := Form.WindowProc;
  Form.WindowProc := WndProc;
end;

procedure TFormObj.DoRepaint;
  procedure RepaintBtnControls(TheCtrl: TControl);
  // This method made by J Hamblin - Qtools Software.
  var
    i: integer;
  begin
    if not (TheCtrl is TWinControl) or (TheCtrl is TBitBtn) then
      exit;

    // repaint only controls of affected type
    if (TheCtrl is TButtonControl) or (TheCtrl is TStaticText) then
    begin
      TWinControl(TheCtrl).Repaint;
      exit; // TButtonControls, TStaticText do not contain controls so skip rest
    end;

    //

    for i := 0 to TWinControl(TheCtrl).ControlCount - 1 do
    begin
      // only paint controls on active tabsheet of page control
      if (TheCtrl is TTabSheet) and
          (TTabSheet(TheCtrl).PageIndex <> TTabSheet(TheCtrl).PageControl.ActivePageIndex) then
        continue;
      // recurse
      RepaintBtnControls(TWinControl(TheCtrl).Controls[i]);
    end;
  end;

  procedure DoRepaint(Ctrl: TControl);
  var
    i: integer;
  begin
    if (Ctrl is TWinControl) then
    begin
      TWinControl(Ctrl).Repaint;
      for i := 0 to TWinControl(Ctrl).ControlCount - 1 do
        DoRepaint(TWinControl(Ctrl).Controls[i]);
    end;
  end;

begin
  if NeedRepaint then
  begin
    NeedRepaint := False;
    if RepaintAll then
      DoRepaint(Form)
    else
      RepaintBtnControls(Form);
  end;
end;

procedure TFormObj.WndProc(var Message: TMessage);
begin
  OrgProc(Message);
  if (Message.Msg = WM_UPDATEUISTATE) then
    NeedRepaint := True;
end;

end.

Mike_on_Tour 28. Jan 2008 10:30

Re: Buttons und Labels verschwinden
 
Hallo Sven,

das ist ja gleich etwas sehr ausführlich. Aber damit kann ich was anfangen. Besten Dank.

Mike

BenjaminH 18. Apr 2010 12:24

Re: Buttons und Labels verschwinden
 
Ich habe nach verwenden dieser Komponente das Problem, dass nach einmaligem drücken der Alt-Taste die Unterstreichungen nicht wieder verschwinden.(Win 7)
Kann jemand das Problem nachvollziehen?

Viele Grüße,
Benjamin


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:32 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