Public class WIN32API
{
[System. runtime. interopservices. dllimport ("user32.dll")]
Public static extern bool ptinrect (ref rectangle R, point P );
}
/// <Summary>
/// Dock to the top
/// </Summary>
Private void berthtop (Object sender, eventargs E)
{
System. Drawing. Point pp = new point (cursor. position. X, cursor. position. y );
Rectangle rects = new rectangle (this. Left, this. Top, this. Left + this. Width, this. Top + this. Height );
If (this. Top <0) & WIN32API. ptinrect (ref rects, pp ))
{
This. Top = 0;
}
Else if (this. Top>-5) & (this. Top <5 )&&! (WIN32API. ptinrect (ref rects, pp )))
{
This. Top = 5-This. height;
}
}
Private void settouming ()
{
Frmsetopaticy OPA = new frmsetopaticy (this );
Opa. startposition = formstartposition. centerscreen;
Opa. showdialog (this );
}
// Private void timereffectick (Object sender, eventargs E)
//{
// System. Drawing. Point pp = new point (cursor. position. X, cursor. position. Y); // obtain the coordinate point of the mouse on the screen
// Rectangle rects = new rectangle (this. left, this. top, this. left + this. width, this. top + this. height); // store the current form in the area of the screen
// If (this. Top <0) & WIN32API. ptinrect (ref rects, pp) // when the cursor is in the current form, and the top attribute of the form is smaller than 0
// This. Top = 0; // set the top attribute of the form to 0, that is, to close the upper edge of the window to the top
// Else if (this. Top>-5 & this. Top <5 &&! (WIN32API. ptinrect (ref rects, pp) // when the distance between the upper border of the form and the top of the screen is less than 5
// This. Top = 5-This. height; // hide the QQ form to the top of the screen
//}