Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Found it! Here is the proof:</p> <p><img src="https://i.stack.imgur.com/ts9zE.png" alt="alt text"></p> <p>As you can see, the drop shadow now shows properly over the form.</p> <p>The problem was one of Z-order. It turns out that the shadow is itself a separate window maintained by Windows itself. In Windows 7, it seems to show the shadow underneath the main window. In order to get it to display properly, one needs to move it up.</p> <p>A genius called Łukasz Płomiński explained this in a thread in the Embarcadero newsgroup. Here is his code to sort it out:</p> <pre><code>procedure TForm1.FixSysShadowOrder; function FindSysShadowOrderProc(WindowHandle: HWND; // handle to window Form: TForm1 // application-defined value, 32-bit ): BOOL; stdcall; var Buffer: array [0 .. 255] of char; Rect: TRect; begin Result := True; if IsWindowVisible(WindowHandle) then begin // this code search for SysShadow window created for this window. GetClassName(WindowHandle, Buffer, 255); if 0 &lt;&gt; AnsiStrComp(Buffer, PChar('SysShadow')) then Exit; GetWindowRect(WindowHandle, Rect); if (Rect.Left &lt;&gt; Form.Left) or (Rect.Top &lt;&gt; Form.Top) then Exit; Form.FSysShadowHandle := WindowHandle; // stop enumeration Result := False; end; end; begin if not(csDesigning in ComponentState) and ((GetClassLong(Handle, GCL_STYLE) and CS_DROPSHADOW) = CS_DROPSHADOW) and IsWindowVisible(Handle) then begin // for speed, proper SysShadow handle is cached if FSysShadowHandle = 0 then EnumThreadWindows(GetCurrentThreadID(), @FindSysShadowOrderProc, lParam(Self)); // if SysShadow exists, change its z-order, and place it directly below this window if FSysShadowHandle &lt;&gt; 0 then SetWindowPos(FSysShadowHandle, Handle, 0, 0, 0, 0, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOOWNERZORDER or SWP_NOSIZE); end; end; </code></pre> <p>You have to work out when to call <code>FixSysShadowOrder()</code>, because Z orders change, and it won't stay right. Łukasz suggested calling it in an idle routine (for example when updating an Action), and on receipt of <code>WM_WINDOWPOSCHANGED</code> message. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload