AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi 7 + Vista Ready Code = ShowModal Problem
Thema durchsuchen
Ansicht
Themen-Optionen

Delphi 7 + Vista Ready Code = ShowModal Problem

Ein Thema von Shark99 · begonnen am 12. Aug 2010 · letzter Beitrag vom 12. Aug 2010
Antwort Antwort
Shark99

Registriert seit: 16. Mai 2007
403 Beiträge
 
#1

Delphi 7 + Vista Ready Code = ShowModal Problem

  Alt 12. Aug 2010, 20:12
Ich benutze den Code von dieser Seite damit meine App in der Taskbar das Preview Bild bekommt:

Quelle: http://www.installationexcellence.co...nal/Index.html
Delphi-Quellcode:
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
  GetWindowLong(Application.Handle, GWL_EXSTYLE) and not WS_EX_APPWINDOW
  or WS_EX_TOOLWINDOW);

ShowWindow(Application.Handle, SW_SHOW);
Delphi-Quellcode:
procedure TMainForm.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.ExStyle := Params.ExStyle and not WS_EX_TOOLWINDOW or
    WS_EX_APPWINDOW;
end;
Delphi-Quellcode:
interface

protected
procedure WMSyscommand(var Message: TWmSysCommand); message WM_SYSCOMMAND;

implementation

procedure TMainForm.WMSyscommand(var Message: TWmSysCommand);
begin
  case (Message.CmdType and $FFF0) of
    SC_MINIMIZE:
    begin
      ShowWindow(Handle, SW_MINIMIZE);
      Message.Result := 0;
    end;
    SC_RESTORE:
    begin
      ShowWindow(Handle, SW_RESTORE);
      Message.Result := 0;
    end;
  else
    inherited;
  end;
end;
So weit so gut, aber nun kommt der vierte Schritt:
Delphi-Quellcode:
procedure TMainForm.AboutActionExecute(Sender: TObject);
begin
  AboutForm := TAboutForm.Create(Self);
  try
    AboutForm.PopupParent := Self;
    AboutForm.ShowModal;
  finally
    FreeAndNil(AboutForm);
  end;
end;
Dieser geht nicht weil Delphi 7 kein PopupParent kennt.

Durch die Suchfunktion habe ich leider keine Lösung gefunden.
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

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

AW: Delphi 7 + Vista Ready Code = ShowModal Problem

  Alt 12. Aug 2010, 20:24
PopupParent ist ein Property eines TPopupMenu ... wieso sollte eine About-TForm dieses also besitzen?

Laß diese Zeile einfach mal weg und schau was passiert.
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Shark99

Registriert seit: 16. Mai 2007
403 Beiträge
 
#3

AW: Delphi 7 + Vista Ready Code = ShowModal Problem

  Alt 12. Aug 2010, 21:27
Wenn ich diese Zeile weglasse, passiert ja dieses Problem: MainForm -> Showmodal Aboutform. In eine andere Anwendung wechseln, zurück zu meiner App über Taskbar. Ergebnis: Mainform sichtbar, Aboutform ist dahinter (obwohl Modal). Mainform reagiert dadurch nicht mehr, App ist also quasi crashed.

PopupParent ist sehr Wohl ein TForm Property, aber erst ab D2006 oder D2007. Es löst genau dieses Problem.

Das ganze in der Quelle die ich angegeben hab:

This is because, by default, Delphi sets the hidden “application form” as the parent of modal forms. To fix this, you must set Form.PopupParent before every call to Form.ShowModal.
  Mit Zitat antworten Zitat
Peter1999

Registriert seit: 13. Dez 2007
Ort: Dresden
88 Beiträge
 
Delphi XE2 Professional
 
#4

AW: Delphi 7 + Vista Ready Code = ShowModal Problem

  Alt 12. Aug 2010, 21:50
Der "showmodal-bug" gehört schon zu den Klassikern in Delphi und wurde auch schon mehrfach diskutiert.
In D7 gibt ist einen einfachen workaround. Schlagwort zum Googeln: Disable Window Ghosting

Delphi-Quellcode:
procedure DisableProcessWindowsGhosting;
var
  DisableProcessWindowsGhostingImp : procedure;
begin
  @DisableProcessWindowsGhostingImp :=
    GetProcAddress(GetModuleHandle('user32.dll'),
    'DisableProcessWindowsGhosting');
  if (@DisableProcessWindowsGhostingImp <> nil) then
    DisableProcessWindowsGhostingImp;
end;


// In der Projekt.dpr
begin
  // Disable Window Ghosting anwenden:
  DisableProcessWindowsGhosting;
  Application.Initialize;
  Application.Title := 'Hidden Dialog Test';
  Application.CreateForm(TfrmMain, frmMain);
  Application.Run;
end.
Viele Grüße,
Peter
  Mit Zitat antworten Zitat
Shark99

Registriert seit: 16. Mai 2007
403 Beiträge
 
#5

AW: Delphi 7 + Vista Ready Code = ShowModal Problem

  Alt 12. Aug 2010, 22:00
Peter - ich habs gemacht, leider wurde das Problem nicht gelöst. Der About Dialog verschwindet immer noch in den Hintergrund.
Hab auch versucht in CreateParams des About Fensters params.WndParent umzubiegen, ohne Erfolg.

Geändert von Shark99 (12. Aug 2010 um 22:05 Uhr)
  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 01:16 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