Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   CS_DROPSHADOW auf TForm wird erst bei Alt+TAB angezeigt (https://www.delphipraxis.net/175620-cs_dropshadow-auf-tform-wird-erst-bei-alt-tab-angezeigt.html)

Mossi 4. Jul 2013 08:42

Delphi-Version: 7

CS_DROPSHADOW auf TForm wird erst bei Alt+TAB angezeigt
 
Hallo zusammen,

ich hab eine Basisklasse für verschiedene modale Dialoge erstellt und will für diese Dialoge haben, dass da immer ein Schatten angezeigt wird.
Die Basisklasse setzt BorderStyle auf bsNone.
Um den Schatten anzuzeigen verwende ich CS_DROPSHADOW in CreateParams:
Delphi-Quellcode:
procedure TBorderlessDialog.CreateParams(var Params: TCreateParams);
const
  CS_DROPSHADOW = $00020000;
begin
  inherited CreateParams(Params);
  with Params do
  begin
    Style := WS_POPUP;
    WindowClass.Style := WindowClass.Style or CS_DROPSHADOW;
  end;
end;
Jetzt hab ich aber das Problem, dass der Schatten erst dann angezeigt wird, wenn ich mit Alt+TAB in ein anderes Programm wechsle, als ob die Form nicht komplett gezeichnet werden würde. Kann ich das irgendwie erzwingen, dass der Schatten gezeichnet wird.

Achja: Interessant könnte auch noch sein, dass es manchmal auch sofort funktioniert.

Ich weiß da echt nicht mehr weiter.

Optional freue ich mich auch über Tips, wie man anderweitig einen Schatten um ein rahmenloses Fenster zeichnen könnte. Oder im Idealfall gleich um eine Fertige Basisklasse, die das übernimmt :-)

Der schöne Günther 4. Jul 2013 09:03

AW: CS_DROPSHADOW auf TForm wird erst bei Alt+TAB angezeigt
 
MSDN:
Zitat:

If you're hoping to make a temporary popup control in your window and want to use CS_DROPSHADOW to reinforce the fleeting nature of the popup, you can't use it with WS_CHILD -- it just ignores CS_DROPSHADOW. You'll need to make your control be WS_POPUP and then position it where you want it when it opens.
MSDN:
Zitat:

Windows created from a class with this style must be top-level windows; they may not be child windows.

Mossi 4. Jul 2013 09:13

AW: CS_DROPSHADOW auf TForm wird erst bei Alt+TAB angezeigt
 
Danek für die Antwort, aber das versteh ich nicht ganz.

Ich weise ich den Style WS_POPUP im CreateParams zu. Was muss ich noch machen, um ein Fenster als WS_POPUP zu erzeugen?
Desweiteren die Sache mit den Top-Level Windows: Heißt das, dass das nie zuverlässig funktionieren wird, wenn es sich um Dialoge in einer Anwendung handelt?

Hier die Stelle, an der ich ein solches Fenster erzeuge:
Delphi-Quellcode:
if formGetBookmark = nil then
  formGetBookmark := TFormGetBookmark.Create(Application);
formGetBookmark.ShowModal;
formGetBookmark.Free;
formGetBookmark := nil;


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