alphablend aktywnego okna i pozostałych

0

jak zrobic aby wszystkie otwarte okna w systemie mialy alphablendvalue ustawione na przyklad na 100 a aktywne okno na 255 ?

wiem ze bedzie trzeba pobrac uchwyty , ale jak pobrac je z wszystkich aplikacju i jak wyslac do nich alphablendvalue ?

0

Okna znajdziesz używając EnumWindows.

0

Nota bene - interesujący pomysł. Ciekawe jak to wygląda w praniu :)

0

tylko ze ja z uchwytami okien ciezko mam wiec gdybyscie mogli pomoc...

tak na prawde mam fajny pomysl na program i na jego obsluge lecz nie wiem jak powysylac komunikaty do wszystkich okien

0

greenmag gratuluję pomysłu! Efekt jest świetny! Szkoda, że trochę spada "wydajność"
http://qyon.satanbsd.org/bin/efekt.jpg

0

Problemem jest tylko dostarczenie naszemu programowi informacji, że jakieś okno stało się aktywne. Nigdy nie bawilem się hookami i nie wiem czy można dać hook na takie coś.

W ostateczności hook na kliknięcie myszą i porównujemy handle_ostatniego_zapamiętanego_aktywnego_okna z aktualnie aktywnym oknem.

Jeśli się różnią, to:

uchwyt_aktywnego_okna := GetActiveWindow;
EnumWindows(adres_naszej_funkcji, 1234);

gdzie nasza_funkcja ma 2 parametry (zgodnie z win32.hlp)

BOOL CALLBACK EnumWindowsProc(
    HWND hwnd,	// handle to parent window
    LPARAM lParam 	// application-defined value
   );

W treści tej funkcji robisz:

if hwnd = uchwyt_aktywnego_okna then
 SetLayeredWindowAttributes(hwnd, nil, 255, LWA_ALPHA);
else
 SetLayeredWindowAttributes(hwnd, nil, 100, LWA_ALPHA);

To powinno załatwić sprawę. Podziel się kodem z innymi jak napiszesz :)
I nie pisz, że dostałeś za mało informacji [diabel]

0
Marooned napisał(a)
if hwnd = uchwyt_aktywnego_okna then
 SetLayeredWindowAttributes(hwnd, nil, 255, LWA_ALPHA);
else
 SetLayeredWindowAttributes(hwnd, nil, 100, LWA_ALPHA);

Zamiast

nil

trzeba 0 ;)

No i wydaje mi się że będzie to działać tylko jesli forma ma ustawione AlphaBlend na True ale może się mylę... :P

A efekt faktycznie super [soczek]

//przepisywałem to z BCB i tam miałem NULL więc zamieniłem na nil ;) nie piszę w Delphi - M

0

Świetne to! - gdyby tak ustawić wszystkie formy..hmm - zaraz zaczne to kodzić :]

user image</image>

user image

0

bardzo sie ciesz ze pomysl sie spodobal
lecz dzis juz nic nie zrobie bo na nocke do pracy ide
jak cos jeszcze wykombinujecie to wstawcie linki
[browar]
jutro biore sie do roboty !

0

No... fajne to :) ale to taki OT: bedzie to dzialac pod win98 ? :)
/// do postu poniżej
:(

0
LukaStrz napisał(a)

No... fajne to :) ale to taki OT: bedzie to dzialac pod win98 ? :)

pewnie nie :/
na pewno nie ...
2000 / XP

0

Proszę, oto przykładzik który pomoże. Umożliwia on ustalanie oknom/aplikacjom przeźroczystości.

  1. http://www.traxa.pl/file.php?file=631d85dc3ac1d4de4cedb001c86f3622
  2. http://www.uploader.pl/file/1830/AlphaBlend-innych-okien-aplikacji.rar.html
    lub
  3. http://www.plikownik.pl/756447

Kod (nie jest sformatowany, więc od razu zaznaczam, że to nie mój ;p), jeśli nie można pobrać w/w pliku:

unit FW;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, ValEdit, ComCtrls, ExtCtrls, Spin;

type
  TForm1 = class(TForm)
    ButtonOnTop: TButton;
    ListView1: TListView;
    Timer1: TTimer;
    SpinEdit1: TSpinEdit;
    Label1: TLabel;
    Label2: TLabel;
    TrackBar1: TTrackBar;
    ButtonTranslucentSet: TButton;
    ButtonTranslucentReset: TButton;
    Shape1: TShape;
    ColorDialog1: TColorDialog;
    CheckBoxTranslucent: TCheckBox;
    CheckBoxBlend: TCheckBox;
    Bevel1: TBevel;
    procedure FormCreate(Sender: TObject);
    procedure ButtonOnTopClick(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);
    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure SpinEdit1Exit(Sender: TObject);
    procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ButtonTranslucentSetClick(Sender: TObject);
    procedure ButtonTranslucentResetClick(Sender: TObject);
    procedure CheckBoxTranslucentClick(Sender: TObject);
  private
    { Private declarations }
    Procedure Refresh;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Handles: Array of THandle;

implementation

{$R *.dfm}
procedure TForm1.Refresh;
var
  WinHandle :Cardinal;
  TitleBar : AnsiString;
  Size, i, TopPos: Integer;
  Item: TListItem;
  Info:TWINDOWINFO;
  Selected : AnsiString;
begin
 Selected:='';

if ListView1.Items.Count>0 then
begin
   if ListView1.ItemIndex<>-1 then Selected:=ListView1.Items[ListView1.ItemIndex].SubItems[1];
   TopPos:=ListView1.TopItem.Index;
end
else TopPos:=0;

ListView1.Items.BeginUpdate;
ListView1.Clear;
WinHandle:=GetTopWindow(0);
repeat
  WinHandle:=GetWindow(WinHandle, GW_HWNDNEXT);
  if WinHandle=0 then Break;
  Size:=GetWindowTextLength(WinHandle);
  SetLength(TitleBar,Succ(Size));
  GetWindowText(WinHandle,PAnsiChar(TitleBar),Succ(Size));
  if (Length(TitleBar)>1) and IsWindowVisible(WinHandle) then
  begin
     Item:=ListView1.Items.Add;
     Item.Caption:=TitleBar;

    Info.cbSize:=SizeOf(Info);
    GetWindowInfo(WinHandle,Info);

    if (Info.dwExStyle and WS_EX_TOPMOST)<>0 thenItem.SubItems.Add('T')
    else Item.SubItems.Add('');
    Item.SubItems.Add(IntToStr(WinHandle));
   end;

until 0<>0;
ListView1.Items.EndUpdate;
ListView1.Scroll(0,TopPos*(Abs(ListView1.Font.Height)+4));

if Selected<>'' then
  for i:=0 to Pred(ListView1.Items.Count) do
    if ListView1.Items[i].SubItems[1]=Selected then
      begin
        ListView1.ItemIndex:=i;
        Break;
      end;

if Form1.Visible then ListView1.SetFocus;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Left:=0;
  Top:=0;
  Refresh;
end;

procedure TForm1.ButtonOnTopClick(Sender: TObject);
var
  Uchwyt:Cardinal;
begin
  if ListView1.SelCount=0 then Exit;
  Uchwyt:=StrToInt64(ListView1.Items[ListView1.ItemIndex].SubItems[1]);

  case (Sender as TButton).Caption[1] of
     'O': SetWindowPos(Uchwyt,HWND_TOPMOST,    //OnTop
       0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
     'D': SetWindowPos(Uchwyt,HWND_NOTOPMOST,    //DeOnTop
       0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
  end;

  Refresh;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
ListView1.Columns[0].Width:= ListView1.Width-ListView1.Columns[1].Width-GetSystemMetrics(SM_CXVSCROLL)-4;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Refresh;
end;

procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
  if StrToIntDef(SpinEdit1.Text,-1)<>-1 then
  Timer1.Interval:=SpinEdit1.Value*1000;
  ListView1.SetFocus;
end;

procedure TForm1.ListView1SelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
begin
  if Item.SubItems[0]='T' then ButtonOnTop.Caption:='DeOnTop'
  else ButtonOnTop.Caption:='OnTop';
end;

procedure TForm1.SpinEdit1Exit(Sender: TObject);
begin
  if StrToIntDef(SpinEdit1.Text,-1)=-1 then SpinEdit1.Value:=3;
end;

procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if ColorDialog1.Execute then Shape1.Brush.Color:=ColorDialog1.Color;
end;

procedure TForm1.ButtonTranslucentSetClick(Sender: TObject);
var
  Uchwyt:Cardinal;
  effect: Integer;
begin
  if ListView1.SelCount=0 then Exit;
  effect:=0;
  if CheckBoxBlend.Checked then effect:=effect+LWA_ALPHA;
  if CheckBoxTranslucent.Checked then effect:=effect+LWA_COLORKEY;

  Uchwyt:=StrToInt64(ListView1.Items[ListView1.ItemIndex].SubItems[1]);
  // Set WS_EX_LAYERED on this window
  SetWindowLong(Uchwyt, GWL_EXSTYLE,
  GetWindowLong(Uchwyt, GWL_EXSTYLE) or WS_EX_LAYERED);
  // apply effects
  SetLayeredWindowAttributes(Uchwyt, Shape1.Brush.Color,
                          (255 * TrackBar1.Position) div 100,
                            effect);
  Refresh;
end;

procedure TForm1.ButtonTranslucentResetClick(Sender: TObject);
var
  Uchwyt:Cardinal;
begin
  if ListView1.SelCount=0 then Exit;
  Uchwyt:=StrToInt64(ListView1.Items[ListView1.ItemIndex].SubItems[1]);

  // Remove WS_EX_LAYERED from this window styles
  SetWindowLong(Uchwyt, GWL_EXSTYLE,
        GetWindowLong(Uchwyt, GWL_EXSTYLE) and (not WS_EX_LAYERED));
  // Ask the window and its children to repaint
  RedrawWindow(Uchwyt, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or
        RDW_ALLCHILDREN);

  Refresh;
end;

procedure TForm1.CheckBoxTranslucentClick(Sender: TObject);
begin
  ButtonTranslucentSet.Enabled:= (CheckBoxTranslucent.Checked or CheckBoxBlend.Checked);
end;

end.

1 użytkowników online, w tym zalogowanych: 0, gości: 1