Question

I'm building an app which needs display a particular form always on top (this is a customer request), so far I'm using the SetWindowPos function with the HWND_TOPMOST value, and that works fine, but when the Windows 7 Flip 3D feature is activated my app doesn't stay in top.

Windows 7 Flip 3D

enter image description here

The question is, how my form can stay on top of all the others windows even if the Windows 7 Flip 3D is activated?

Was it helpful?

Solution

I do this some time ago using the DwmSetWindowAttribute function modyfing the DWMWA_FLIP3D_POLICY attribute with the DWMFLIP3D_EXCLUDEABOVE value.

Try this code

uses
  Winapi.DwmApi;

procedure TForm40.FormCreate(Sender: TObject);
var
  pvAttribute: Integer;
begin
  pvAttribute:= DWMFLIP3D_EXCLUDEABOVE;
  if DwmCompositionEnabled then
   DwmSetWindowAttribute(Handle, DWMWA_FLIP3D_POLICY, @pvAttribute, Sizeof(Integer));
end;

And this is the result

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top