Thema: Delphi alpha key - transparency

Einzelnen Beitrag anzeigen

Benutzerbild von sk.Silvia
sk.Silvia

Registriert seit: 8. Feb 2006
Ort: Slovenia
90 Beiträge
 
Delphi 7 Personal
 
#1

alpha key - transparency

  Alt 28. Feb 2006, 14:06
i found out how to make transparetnt windows in delphi


Delphi-Quellcode:
const
  WS_EX_LAYERED = $80000;
  LWA_COLORKEY = 1;
  LWA_ALPHA = 2;

type
 TSetLayeredWindowAttributes = function (
     hwnd : HWND; // handle to the layered win8dow
     crKey : TColor; // specifies the color key
     bAlpha : byte; // value for the blend function
     dwFlags : DWORD // action
     ): BOOL; stdcall;

procedure SetTransparentForm(AHandle : THandle; AValue : byte = 0);
  var Info: TOSVersionInfo;
      SetLayeredWindowAttributes: TSetLayeredWindowAttributes;

  begin
  //Check Windows version
  Info.dwOSVersionInfoSize := SizeOf(Info);
  GetVersionEx(Info);
  if (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) and (Info.dwMajorVersion >= 5) then
      begin
      SetLayeredWindowAttributes := GetProcAddress(GetModulehandle(user32), 'SetLayeredWindowAttributes');
      if Assigned(SetLayeredWindowAttributes) then
        begin
        SetWindowLong(AHandle, GWL_EXSTYLE, GetWindowLong(AHandle, GWL_EXSTYLE) or WS_EX_LAYERED);
        //Make form transparent
        SetLayeredWindowAttributes(AHandle, 0, AValue, LWA_ALPHA);
        end;
      end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 SetTransparentForm(Handle, 255);
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
  begin
   SetTransparentForm(Handle,TrackBar1.Position);
   Application.ProcessMessages;
  end;
this works on the whle form
now, how could i make any object transparent? or have different transparency on different possitions of the form?
i heared sometthing about alpha key or smt like that but dont know more
  Mit Zitat antworten Zitat