2004. október 2., szombat

Great Looking Transparent Forms, Strange Shaped !


Problem/Question/Abstract:

Using This Code, You Can Make Some Unique Looking Forms, Transparent, Multi-shaped and more !!

Answer:

////////////////////////////////////////////////////////////////////////
/////// TRIED ON WINDOWS 2000 PROFESSIONAL AND SERVER WITH DELPHI 5
/////// PLEASE DO NOT TRY TO DEFINE ANY VALUES< MAY CAUSE ERROS
////////////////////////////////////////////////////////////////////////

Hi Everybody,

in a late time in the evening, i started digging in this code, and here is the result, to try it and see the results your self, please do the following......

1- Start A New Project In Delphi 5
2- Make Sure JPEG Is In Your Windows Clause
3- Add These Lines


const
  WS_EX_LAYERED = THE - SECRET - CODE - HERE - - -LOOK - COMMENT;

  LWA_COLORKEY = 1; //1
  LWA_ALPHA = 2; //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;


You Saw (THE-SECRET-CODE-HERE---LOOK-COMMENT) Above A Minute Ago, In This Place Add Any Of The Following Values

Const

$81111 Form Caption Flipped
$82222 Form Visible But Can Never Get Focused
$83333 Form Caption Flipped And Never Gets Focus
$80FFF Form is (bsToolWindow), Never Maximized, Never Gets Focused
$FFFFF Form is (bsToolWindow), Form Flipped, Never Gets Focus, Never Maximizes
$222222 Very Strange Behaviour On Form Move, Try It !!
$222000 Form Looks As In Win 3.11 Applications
$333333 Captionless Window, Never Moves
#333000 Form Like In Win 3.11 Applications, Caption Flipped
$444444 The Whole Form With Everything On It Is Flipped
$444888 The Whole Form With Everything On It Is Flipped, It Is Converted To (bsToolWindow)
$555555 Form And All Contents Are Flipped, But Caption Still In Place ( Not Flipped )
$555888 Form And All Contents Are Flipped, But Caption Still In Place ( Not Flipped ), It Is

Converted To (bsToolWindow)
$666666 Form And All Contents Are Flipped, Win 3.11 GUI
$666888 Form And All Contents Are Flipped, Win 3.11 GUI, (bsTooWindow)

$777000 This Is Strange, Looks Like A 16bit Application, Everything Flipped, Caption In Place ***BUT***, Windows Accesses Your Form As If It Was Not A Part Of Your Application, I Mean, When Minimizing Application, You Will See One Entry In The Taskbar, When Restoring It, Every Form Will Have Its Own Entry, Well, It Makes An MDI Like Application !!

$777888 The Same But The MDI Form Will Have No Icon At All.
$888888 (bsToolWindows) Transparent Form
$888000 Normal Transparent Form
$888FFF (bsToolWindows) Transparent Form, Cant Get Focused
$8F8F8F (bsToolWindows) Transparent Form, MDI Alike
$999999 Transparent (bsToolWindow) Form, Caption Flipped
$999000 Transparent Form, Caption Flipped
$999FFF Transparent (bsToolWindow) Form, Caption Flipped, Never Focused


4- In Your FormCreate Event, Place This Code

var
  Info: TOSVersionInfo;
  F: TSetLayeredWindowAttributes;
begin
  inherited;
  Info.dwOSVersionInfoSize := SizeOf(Info);
  GetVersionEx(Info);
  if (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) and
    (Info.dwMajorVersion >= 5) then
  begin
    F := GetProcAddress(GetModulehandle(user32),
      'SetLayeredWindowAttributes');
    if Assigned(F) then
    begin
      SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle,
        GWL_EXSTYLE) or WS_EX_LAYERED);
      F(Handle, 1, Round(255 * 75 / 100), LWA_ALPHA);
    end;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése