Source Code如下:
Unit1.cpp /--------------------------------------------------------------------------- #include
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Label1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if( Button == mbLeft)
{
long lStyle;
lStyle=GetWindowLong(Handle, GWL_EXSTYLE );
lStyle |= 0x00080000;
SetWindowLong(Handle, GWL_EXSTYLE, lStyle ); // 設定半透明, 參數3: 0=全透明 , 255為不透明
for (int i = 255 ; i >= 105; i-=4)
{
SetLayeredWindowAttributes(Handle, RGB(255,0,255), i,3); //現在設為 150,即半透明狀態
} ReleaseCapture();
Perform( WM_SYSCOMMAND, 0xf012, 0 );
Application->ProcessMessages(); for (int i = 55 ; i <= 255; i =10)
{
SetLayeredWindowAttributes(Handle, RGB(255,0,255), i,3); //現在設為 150,即半透明狀態
}
} }
//--------------------------------------------------------------------------- Unit1.H //--------------------------------------------------------------------------- #ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp>
#include
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TImage *Image1;
TButton *Button1;
TLabel *Label1;
TLabel *Label2;
TEdit *Edit1;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Label1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
/*生活是一種藝術,用心生活才能享受生活*/