Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi DWM Shadow (https://www.delphipraxis.net/192082-dwm-shadow.html)

EWeiss 18. Mär 2017 15:45

DWM Shadow
 
Ich hab ne Funktion für DWM Shadow erstellt aber der Schatten wird nicht gezeichnet.
woran liegst?

Schatten wird erstellt nach der Anzeige des Window.
Delphi-Quellcode:
// Window Anzeigen
SKAERO_ShowMainWindow(gp.hMain, 5);
SKAERO_EnableShadow(gp.hMain);
WindowStyle
Delphi-Quellcode:
dwStyle := WS_POPUP or WS_CLIPSIBLINGS or WS_CLIPCHILDREN;
Delphi-Quellcode:
function DWM_ExtendFrameIntoClientArea(hWnd: hWnd; ATopHeight, ALeftWidth, ABottomHeight,
  ARightWidth: Integer): HRESULT;
var
  Margins: TMargins;
begin
  Margins.cyTopHeight := ATopHeight;
  Margins.cyBottomHeight := ABottomHeight;
  Margins.cxLeftWidth := ALeftWidth;
  Margins.cxRightWidth := ARightWidth;
  Result := S_FALSE;

  if IsDWMloaded then
    Result := DwmExtendFrameIntoClientArea(hWnd, @Margins);
end;
Delphi-Quellcode:
function TSkinEngine.EnableShadow(WinHandle: hWnd): HRESULT;
var
  val: TDWMNCRENDERINGPOLICY;
begin

  Result := -1;
  if IsCompositionEnabled then
  begin
    val := DWMNCRP_ENABLED;
    DwmSetWindowAttribute(WinHandle, DWMWA_NCRENDERING_POLICY, @val, DWMWA_ALLOW_NCPAINT);

    Result := DWM_ExtendFrameIntoClientArea(WinHandle, -1, -1, -1, -1); // result := 0 sollte also in Ordnung sein.
  end;
end;
gruss

EWeiss 18. Mär 2017 23:16

AW: DWM Shadow
 
So geht es.
Delphi-Quellcode:
function TSkinEngine.EnableShadow(WinHandle: hWnd): HRESULT;
var
  Policy: LongInt;
begin

  Result := -1;
  if IsCompositionEnabled then
  begin
    Policy := DWMNCRP_ENABLED;
    DwmSetWindowAttribute(WinHandle, DWMWA_NCRENDERING_POLICY, @Policy, SizeOf(Policy));

    Result := DWM_ExtendFrameIntoClientArea(WinHandle, -1, -1, -1, -1);
  end;
end;
irgendwie erschließt sich das mir nicht.
Meiner Meinung nach wäre das richtig.
Delphi-Quellcode:
var
  Policy: TDWMNCRENDERINGPOLICY;
Dann bekomme ich aber keinen Schatten.

Bei dieser Version gibt es aber auch wieder ein Problem.
Sobald ich ein anderes Fenster öffne verschwindet der Schatten von meinem Window.

Seltsam das ganze.

Auch das ist seltsam funktioniert genauso mit dem vorher genannten Problem

Delphi-Quellcode:
DwmSetWindowAttribute(WinHandle, DWMWA_NCRENDERING_POLICY, @Policy, DWMWA_ALLOW_NCPAINT);


Irgendwie weis keiner was nun richtig übergeben werden muss.
Sobald irgendein anderes Fenster aktiviert wird ist der Schatten weg. (Auch das der IDE)

gruss


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