//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
long wsex = ::GetWindowLongPtr(Handle, GWL_EXSTYLE );
wsex |= WS_EX_TOOLWINDOW ;
wsex &= ~WS_EX_APPWINDOW;
::SetWindowLongPtr(Panel1->Handle, GWL_EXSTYLE, wsex );
::SetParent(Panel1->Handle ,GetDesktopWindow());
SetWindowLong(Panel1->Handle, GWL_EXSTYLE, GetWindowLong(Panel1->Handle, GWL_EXSTYLE ) ^ WS_EX_LAYERED ^ WS_EX_TRANSPARENT );
::SetLayeredWindowAttributes(Panel1->Handle, RGB( 0, 0, 0 ), 255 - 100, LWA_ALPHA );
Panel1->Refresh() ; // 一定要呼叫,否则失败
::SetParent(Panel1->Handle,Form1->Handle);
Panel1->Repaint() ; // 一定要呼叫,否则失败
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CMMove(TMessage &msg) //消息接收处理函数
{
TPoint P;
this->Panel1->Left=this->Left+0.33*this->Width;
this->Panel1->Top=this->Top+0.33*this->Height;
P.y = Panel2->Top + Panel2->Height ; P.x = Panel2->Left;
P=ClientToScreen(P);
Panel1->Top=P.y;
Panel1->Left=P.x ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Panel1->Height = 120;
Image1->Canvas->Rectangle(0,0,Image1->Width,Image1->Height );
Image1->Canvas->Brush->Style = bsClear;
Image1->Canvas->Font->Size =12;Image1->Canvas->Font->Color =clBlue;
Image1->Canvas->TextOutA(10,10," //消息接收处理函数");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel2MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
TPoint P;
ReleaseCapture();
SendMessage(Panel2->Handle , WM_NCLBUTTONDOWN, HTCAPTION,0);
P.y = Panel2->Top + Panel2->Height ; P.x = Panel2->Left;
P=ClientToScreen(P);
Panel1->Top=P.y;
Panel1->Left=P.x ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1Click(TObject *Sender)
{
ShowMessage("hao");
}
//---------------------------------------------------------------------------