//用户名悬浮时 private void lblName_MouseEnter(object sender, EventArgs e) { //窗体的TopLeft值 int UserTop = this.Top + lblName.Top; int UserLeft = this.Left - 279 - 5; //屏幕不包括任务栏的高度 int PH = Screen.GetWorkingArea(this).Height; //判断是否超过屏幕高度 if (UserTop + 181 > PH) { UserTop = PH - 181 - 5; } //判断是否小于屏幕左边 if (UserLeft < 0) { UserLeft = this.Right + 5; } //窗体不为空传值 if (frm != null) { frm.Item = UserItem; frm.Location = new Point(UserLeft, UserTop); frm.Show(); } else //窗体为空New一个 { frm = new FrmUserInformation(UserItem, new Point(UserLeft, UserTop)); frm.Show(); } }
private void chatShow_MouseEnterHead(object sender, ChatListEventArgs e) { //窗体的TopLeft值 int UserTop = this.Top + this.chatShow.Top + (e.MouseOnSubItem.HeadRect.Y - chatShow.chatVScroll.Value); int UserLeft = this.Left - 279 - 5; //屏幕不包括任务栏的高度 int PH = Screen.GetWorkingArea(this).Height; //判断是否超过屏幕高度 if (UserTop + 181 > PH) { UserTop = PH - 181 - 5; } //判断是否小于屏幕左边 if (UserLeft < 0) { UserLeft = this.Right + 5; } //窗体不为空传值 if (frm != null) { frm.Item = e.MouseOnSubItem; frm.Location = new Point(UserLeft, UserTop); frm.Show(); } else //窗体为空New一个 { frm = new FrmUserInformation(e.MouseOnSubItem, new Point(UserLeft, UserTop)); frm.Show(); } }