Ecco un'unità che ho appena messo insieme per te.
Per utilizzare questa unità, rilasciare un componente TApplication nel modulo principale e nella chiamata OnModalBegin _GrayForms e quindi nel metodo OnModalEnd chiamare il metodo _NormalForms.
Questo è un esempio molto semplice e potrebbe essere reso molto più complesso. Verifica di più livelli di chiamata, ecc ....
Per cose come i dialoghi di sistema (aperto, salvataggio, ecc.) È possibile avvolgere il metodo di esecuzione della finestra di dialogo in un tentativo ... infine bloccare le funzioni appropriate per ottenere una reazione simile .
Questa unità dovrebbe funzionare su Win2k, WinXP, Vista e dovrebbe funzionare anche su Win7.
Ryan.
unit GrayOut;
interface
procedure _GrayForms;
procedure _GrayDesktop;
procedure _NormalForms;
implementation
uses windows, classes, forms, Contnrs, Types, Graphics, sysutils;
var
gGrayForms : TComponentList;
procedure _GrayDesktop;
var
loop : integer;
wScrnFrm : TForm;
wForm : TForm;
wPoint : TPoint;
begin
if not assigned(gGrayForms) then
begin
gGrayForms := TComponentList.Create;
gGrayForms.OwnsObjects := true;
for loop := 0 to Screen.MonitorCount - 1 do
begin
wForm := TForm.Create(nil);
gGrayForms.Add(wForm);
wForm.Position := poDesigned;
wForm.AlphaBlend := true;
wForm.AlphaBlendValue := 64;
wForm.Color := clBlack;
wForm.BorderStyle := bsNone;
wForm.Enabled := false;
wForm.BoundsRect := Screen.Monitors[loop].BoundsRect;
SetWindowPos(wForm.handle, HWND_TOP, 0,0,0,0, SWP_NOSIZE or SWP_NOMOVE);
wForm.Visible := true;
end;
end;
end;
procedure _GrayForms;
var
loop : integer;
wScrnFrm : TForm;
wForm : TForm;
wPoint : TPoint;
wScreens : TList;
begin
if not assigned(gGrayForms) then
begin
gGrayForms := TComponentList.Create;
gGrayForms.OwnsObjects := true;
wScreens := TList.create;
try
for loop := 0 to Screen.FormCount - 1 do
wScreens.Add(Screen.Forms[loop]);
for loop := 0 to wScreens.Count - 1 do
begin
wScrnFrm := wScreens[loop];
if wScrnFrm.Visible then
begin
wForm := TForm.Create(wScrnFrm);
gGrayForms.Add(wForm);
wForm.Position := poOwnerFormCenter;
wForm.AlphaBlend := true;
wForm.AlphaBlendValue := 64;
wForm.Color := clBlack;
wForm.BorderStyle := bsNone;
wForm.Enabled := false;
wForm.BoundsRect := wScrnFrm.BoundsRect;
SetWindowLong(wForm.Handle, GWL_HWNDPARENT, wScrnFrm.Handle);
SetWindowPos(wForm.handle, wScrnFrm.handle, 0,0,0,0, SWP_NOSIZE or SWP_NOMOVE);
wForm.Visible := true;
end;
end;
finally
wScreens.free;
end;
end;
end;
procedure _NormalForms;
begin
FreeAndNil(gGrayForms);
end;
initialization
gGrayForms := nil;
end.
fonte
2009-06-30 22:17:51
Si dovrebbe chiarire la tua domanda, dim/svanire tutte le altre finestre di applicazione è diverso dall'effetto Exposé (che non ha un posto su Windows in ogni caso , questo è nient'altro che programmazione settoriale cargo senza la funzionalità Exposé) nel link. – mghie
Si noti che questo comportamento è incoerente con il modo in cui si comportano tutte le altre app sulla piattaforma Windows. Anche se è un effetto piuttosto interessante, è probabile che tu stia solo contribuendo al caos dell'interfaccia che è già la piattaforma Windows. – onnodb