Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi 7 + Vista Ready Code = ShowModal Problem (https://www.delphipraxis.net/153694-delphi-7-vista-ready-code-%3D-showmodal-problem.html)

Shark99 12. Aug 2010 20:12

Delphi 7 + Vista Ready Code = ShowModal Problem
 
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.

himitsu 12. Aug 2010 20:24

AW: Delphi 7 + Vista Ready Code = ShowModal Problem
 
PopupParent ist ein Property eines TPopupMenu ... wieso sollte eine About-TForm dieses also besitzen? :gruebel:

Laß diese Zeile einfach mal weg und schau was passiert.

Shark99 12. Aug 2010 21:27

AW: Delphi 7 + Vista Ready Code = ShowModal Problem
 
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.

Peter1999 12. Aug 2010 21:50

AW: Delphi 7 + Vista Ready Code = ShowModal Problem
 
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

Shark99 12. Aug 2010 22:00

AW: Delphi 7 + Vista Ready Code = ShowModal Problem
 
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.


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