这个功能的实现可以用两种方法:
一个是在Form的OnMouseMove事件中
判断鼠标的位置,隐藏Form
另一个是在Timer的OnTimer事件中
处理,因为鼠标产生的消息太多,所以
我们选用Timer:
代码如下:
void __fastcall TForm1::FormMouseMove(TObject
*Sender,TShiftState Shift,int X,int Y)
{
if(Form1->Top<0)
Form1->Top=0;
}
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if(Form1->Top >0)
return;
GetCursorPos(&CursorPos);
if(CursorPos.x < Form1->Left || CursorPos.x>Form1->Left+Form1->Width
|| CursorPos.y > Form1->Top+Form1->Height)
Form1->Top =10-Form1->Height;
}