请教两个问题:一个是如何提取系统的分辨率;二是如何判断鼠标是否位于某个控件上。 没分了,只能两个问题当一个问!高手指点 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;class Test{ static void Main() { Console.WriteLine(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width); Console.WriteLine(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height); }} MounceEnter事件判断鼠标是否进入控件 [1]好象有个Screen类。[2]供参考private void treeViewNavigator_DragOver(object sender, System.Windows.Forms.DragEventArgs e){//获取鼠标指针位置 Point Position = new Point(0, 0) ; Position.X = e.X ; Position.Y = e.Y ; Position = treeViewNavigator.PointToClient(Position) ; TreeNode DropNode = this.treeViewNavigator.GetNodeAt(Position) ; if ( DropNode != null ) { TreeViewColorReset(this.treeViewNavigator) ; //延时自动展开当前节点 Pub.MarkNode = DropNode ; this.timerExpandNode.Enabled = true ; //标记当前节点颜色 DropNode.BackColor = Color.Navy ; DropNode.ForeColor = Color.White ; e.Effect = DragDropEffects.Copy ; } else { TreeViewColorReset(this.treeViewNavigator) ; e.Effect = DragDropEffects.None ; }} “如何判断鼠标是否位于某个控件上”:我是想把pictureBox当成按扭使用,当鼠标移上去、按下、释放、移开分别在pictureBox上显示不同的图片,我想解决的是当鼠标在pictureBox上按下鼠标后并不释放鼠标而是按住鼠标并离开pictureBox上放后才释放掉鼠标按键,一般在这种情况下是不触发按扭事件的。用MounceEnter之类事件好象不能实现啊 private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e){ this.Text = "pictureBox1_MouseMove" ;}private void pictureBox1_MouseLeave(object sender, System.EventArgs e){ this.Text = "pictureBox1_MouseLeave" ;}private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e){ this.Text = "pictureBox1_MouseDown" ;}private void pictureBox1_MouseEnter(object sender, System.EventArgs e){ this.Text = "pictureBox1_MouseEnter" ;}private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e){ this.Text = "pictureBox1_MouseUp" ;}private void pictureBox1_MouseHover(object sender, System.EventArgs e){ this.Text = "pictureBox1_MouseHover" ;} 虽然ZhouQiang()提供的资料看的不大懂,但从中的到启发!我把判断事件写在MouseUp中,在释放的时候判断:e.X>=0 && e.X<=this.pictureBox1.Width && e.Y>=0 && e.Y<=this.pictureBox1.Height就可以了谢谢楼上诸位! C#怎么实现在指定背景图片上进行画图 DataGridView的问题??????? 画图后的dispose() 抓取网站数据传说能流浏就能爬....[求助] c# listbox 问题 请问如何取得集合中元素的类型 WinForm下如何使TextBox的高度随内容的高度自动调整 问个小问题,判断 ListView 列表中是否选中了某一项该怎么写这个if语句 为什么我打开的oracle连接关闭需要大约1分钟?? ComboBox重绘制问题 怎么样才能实现象QQ一样的菜单效果 treeview控件在ms IE中看起来跟写文本一样,解决了现结贴
{
static void Main()
{
Console.WriteLine(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width);
Console.WriteLine(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
}
}
好象有个Screen类。
[2]
供参考
private void treeViewNavigator_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
//获取鼠标指针位置
Point Position = new Point(0, 0) ;
Position.X = e.X ;
Position.Y = e.Y ;
Position = treeViewNavigator.PointToClient(Position) ;
TreeNode DropNode = this.treeViewNavigator.GetNodeAt(Position) ;
if ( DropNode != null )
{
TreeViewColorReset(this.treeViewNavigator) ;
//延时自动展开当前节点
Pub.MarkNode = DropNode ;
this.timerExpandNode.Enabled = true ;
//标记当前节点颜色
DropNode.BackColor = Color.Navy ;
DropNode.ForeColor = Color.White ;
e.Effect = DragDropEffects.Copy ;
}
else
{
TreeViewColorReset(this.treeViewNavigator) ;
e.Effect = DragDropEffects.None ;
}
}
{
this.Text = "pictureBox1_MouseMove" ;
}private void pictureBox1_MouseLeave(object sender, System.EventArgs e)
{
this.Text = "pictureBox1_MouseLeave" ;
}private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Text = "pictureBox1_MouseDown" ;
}private void pictureBox1_MouseEnter(object sender, System.EventArgs e)
{
this.Text = "pictureBox1_MouseEnter" ;
}private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Text = "pictureBox1_MouseUp" ;
}private void pictureBox1_MouseHover(object sender, System.EventArgs e)
{
this.Text = "pictureBox1_MouseHover" ;
}
e.X>=0 && e.X<=this.pictureBox1.Width && e.Y>=0 && e.Y<=this.pictureBox1.Height
就可以了谢谢楼上诸位!