Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 15-06-2008
[coso] coso is offline
Miembro Premium
 
Registrado: may 2008
Ubicación: Girona
Posts: 1.678
Poder: 0
coso Va por buen camino
Semitransparencia sin alphablend

Semitransparencia sin usar la propiedad alphablend (Windows 2000 y mas)

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
  procedure SetTransparentForm(AHandle : THandle; AValue : byte = 0);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
const
  WS_EX_LAYERED = $80000;
  LWA_COLORKEY = 1;
  LWA_ALPHA    = 2;

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

var


  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.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, 100);
end;

end.
Responder Con Cita
  #2  
Antiguo 15-06-2008
Khronos Khronos is offline
Miembro
 
Registrado: abr 2007
Posts: 298
Poder: 18
Khronos Va por buen camino
El truco está mal, el procedimiento SetTransparentForm hay que ponerlo en el evento OnPaint del Form. Consigues el mismo efecto que con la propiedad AlphaBlend, de echo es el mismo código xD.

Para un delphi anterior al 6 esta bien.

Salu2
Responder Con Cita
  #3  
Antiguo 15-06-2008
[coso] coso is offline
Miembro Premium
 
Registrado: may 2008
Ubicación: Girona
Posts: 1.678
Poder: 0
coso Va por buen camino
bueno si lo pones en OnPaint te estara ejecutando multiples veces algo q solo hace falta ejecutar una vez... a mi me va de perlas en el OnCreate
Responder Con Cita
  #4  
Antiguo 15-06-2008
Khronos Khronos is offline
Miembro
 
Registrado: abr 2007
Posts: 298
Poder: 18
Khronos Va por buen camino
Yo lo probe en el Delphi 5 y en el evento OnCreate no funcionaba.
Responder Con Cita
  #5  
Antiguo 15-06-2008
[coso] coso is offline
Miembro Premium
 
Registrado: may 2008
Ubicación: Girona
Posts: 1.678
Poder: 0
coso Va por buen camino
pues es extraño, tengo delphi 5 yo tambien...
Responder Con Cita
  #6  
Antiguo 15-06-2008
[coso] coso is offline
Miembro Premium
 
Registrado: may 2008
Ubicación: Girona
Posts: 1.678
Poder: 0
coso Va por buen camino
bueno si lo pones en OnPaint te estara ejecutando multiples veces algo q solo hace falta ejecutar una vez... a mi me va de perlas en el OnCreate
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 16:03:50.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi