Arsip: buat Form Transparan ?

 
user image
more 17 years ago

debby

Bisa gak sih form dibuat transparan ? misal aku letakkan Tbutton dlm form1, saat di klik tbutton tsb muncul form2 form2.showmodal; gimana coding agar Form1 tampilannya transparan ? trim's sebelumnya
user image
more 17 years ago

MrLee

pd properties form ada yg nama AlphaBlend buat mjd True & AlphaBlendValue set sesuai yg di butuhkan atau TransparentColor buat mjd True & TransparentColorValue set seusai backgrond form atur warna nya agar hanya background form saja yg hilang semoga berguna
user image
more 17 years ago

ImanD

sample simple-nya with coding

unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;
type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure SetAlphaBlend(hWnd: HWND; IsAlpha: boolean);
    procedure WMNCHitTest(var msg : TWMNCHitTest); message WM_NCHitTest;
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
const
  WS_EX_LAYERED = $00080000;
  LWA_COLORKEY  = $00000001;
  LWA_ALPHA     = $00000002;
var
  DllHnd  : THandle;
  SetLayeredWindowAttributes : function(Hwnd: THandle; crKey: COLORREF;
                                        bAlpha: Byte; dwFlags: DWORD): Boolean stdcall;
function IsWinVersionOK: boolean;
begin
  Result:=((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion >= 5));
  // if Result=true => // Minimal Windows 2000
  //if Result=false => // Sistem operasi tidak mendukung
end;
procedure TForm1.WMNCHitTest(var msg : TWMNCHitTest);
begin
  inherited;
  if (msg.Result = htClient) then
    msg.Result := htCaption;
end;
procedure TForm1.SetAlphaBlend(hWnd: HWND; IsAlpha: boolean);
var
  WinInfo: integer;
begin
  WinInfo:=GetWindowLong(Handle, GWL_EXSTYLE);
  if IsAlpha then
    WinInfo:=WinInfo or WS_EX_LAYERED
  else
    WinInfo:=WinInfo and not WS_EX_LAYERED;
  SetWindowLong(Handle, GWL_EXSTYLE, WinInfo);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
  if IsWinVersionOK then // jika versi Windows mendukung
  begin
    DllHnd := LoadLibrary('user32.dll');
    if DllHnd <> 0 then
      @SetLayeredWindowAttributes := GetProcAddress(DllHnd, 'SetLayeredWindowAttributes')
    else
      exit;
    SetAlphaBlend(Handle, true);
    SetLayeredWindowAttributes(Handle, 0, 200, LWA_ALPHA);
                                        //200 = kadar transparentnya ganti az dengan const lain
  end
end;
end.
user image
more 17 years ago

debby

Thank you for mrlee and Imam D , aku coba ......
user image
more 17 years ago

NiceDream

Delphier yang sudah advance bs coba saran @ImanD, kl yang amatiran kaya saya bs dicoba dengan menggunakan komponen TOpacityForm bs minta tolong cariin sm om gugel. Very Easy Full and Simple, cm dimainin pd nilai properties
more ...
  • Pages:
  • 1
Share to

AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now: https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com