www.demi-s.narod.ru

Delphi
Статьи:

· Интерфейс

· WinAPI

· Компоненты

· Базы данных

· ShellAPI



WinAPI


Создание прозрачных окон

Это - простой модуль для программирования прозрачного Windows на Windows 2000. Вы можете использовать и распределять этот модуль в любой из Ваших программ, потому что это - Свободно распространяемое обеспечение!

Исходный текст проверен в Delphi 3, но будет работать во всех 32-разрядных Delphi версиях.

{
   Layered Window Unit - Version 0.1 ALPHA (Freeware)
   Copyright © 2000 by Hans Wolff

   Homepage: http://www.wolffsoftware.com
   E-Mail:   webmaster@wolffsoftware.com
} unit WinLayer; interface uses Windows; const WS_EX_LAYERED = $80000; LWA_COLORKEY = 1; LWA_ALPHA = 2; var SetLayeredWindowAttributes: function (Handle: HWnd; crKey: TCOLORREF; bAlpha: Byte; dwFlags: DWord): Boolean; stdcall; function IsFeatureEnabled: Boolean; function SetWindowTransparency(Handle: HWnd; Percent: Byte): Boolean; implementation var FeatureEnabled: Boolean; Initialized: Boolean; function InitLayeredWindows: Boolean; var Module: THandle; begin Result:=True; Module:=LoadLibrary('user32.dll'); if (Module=0) then begin Result:=False; Exit; end; SetLayeredWindowAttributes:=GetProcAddress(Module, 'SetLayeredWindowAttributes'); if (Assigned(SetLayeredWindowAttributes)) then FeatureEnabled:=True; Initialized:=True; end; function IsFeatureEnabled: Boolean; begin Result:=True; if (not Initialized) then Result:=InitLayeredWindows; Result:=Result and FeatureEnabled; end; function SetWindowTransparency(Handle: HWnd; Percent: Byte): Boolean; begin Result:=True; if (not Initialized) then Result:=InitLayeredWindows; if ((Result) and (FeatureEnabled)) then begin if (Percent<>0) then begin SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED); SetLayeredWindowAttributes(Handle, 0, (255 * Percent) div 100, LWA_ALPHA); end else begin SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) xor WS_EX_LAYERED); end; end; end; initialization FeatureEnabled:=False; Initialized:=False; end.

Применение: SetWindowTransparency(handle, iPercent);


Hosted by uCoz