有Api的C#例子吗
解决方案 »
- .net框架
- 提示要输入密码,怎么回事呀?
- 翻译了一个最流行最酷的【C#表格控件源代码】文章,送给大家
- XML文件导入数据库 为什么总提示“对于不返回任何基表信息的 SelectCommand 不支持动态 SQL 生成”,网上找不到答案的问题,郁闷中
- 如何把PDA中的文件上传到PC(PDA中操作)?
- 有那位兄弟知道吗??先谢谢了!!!
- C#
- 调用c++的非托管dll成功,但是参数类型string和CString不匹配,怎么解决?
- c#,用StreamWriter把数组的值写入TXT文件中,数据量比较大
- c# 根据一个相同值 修改某一行值 保证位置和数据不变合并2个LIST数组
- 傳奇私服 如何能能得到物品的地址實現自動放藥,和自動解包呢! 请大家帮我看看 C#
- C#取客户端MAC地址(不是通ip得到),内网的也要取的到
而且Beep的声明:
BOOL WINAPI Beep(
__in DWORD dwFreq,
__in DWORD dwDuration
);那么用C#调用时
第一步:声明函数DllImport["Kernel32.dll"]
bool Beep(unsigned int dwFreq, unsigned int dwDuration);具体使用就可以按照上面声明的来做了
{
[DllImport("user32.dll")]
public static extern bool PtInRect(ref Rectangle r, Point p);
} private void timer3_Tick(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);//存储当前窗体在屏幕的所在区域
Rectangle Rects2 = new Rectangle(this.Right, this.Top, this.Right + this.Width, this.Top + this.Height);
if ((this.Top < 0) && Win32API.PtInRect(ref Rects, pp))//当鼠标在当前窗体内,并且窗体的Top属性小于0
this.Top = 0; //设置窗体的Top属性为0,就是将窗口上边沿紧靠顶部
else if (this.Top > -5 && this.Top < 5 && !(Win32API.PtInRect(ref Rects, pp)))//当窗体的上边框与屏幕的顶端的距离小于5时
this.Top = 5 - this.Height;//将QQ窗体隐藏到屏幕的顶端 else if ((this.Left < -150) && Win32API.PtInRect(ref Rects, pp))//当鼠标在当前窗体内,并且窗体的Left属性小于0
this.Left = 0;
else if (this.Left > -5 && this.Left < 5 && !(Win32API.PtInRect(ref Rects, pp)))//将QQ窗体隐藏到屏幕的左端
this.Left = 5 - this.Width; else if (this.Bottom > Screen.AllScreens[0].Bounds.Height + this.Height - 30 && (Win32API.PtInRect(ref Rects, pp)))//当鼠标在当前窗体内,并且窗体底边到屏幕顶部的距离大于屏幕高度+窗体高度—30像素
this.Top = Screen.AllScreens[0].Bounds.Height - this.Height;//窗体紧贴屏幕下方
else if (this.Top == Screen.AllScreens[0].Bounds.Height - this.Height && !(Win32API.PtInRect(ref Rects, pp)))
this.Top = Screen.AllScreens[0].Bounds.Height - 5; //窗体隐藏 else if (this.Right > Screen.AllScreens[0].Bounds.Width + 100 && (Win32API.PtInRect(ref Rects, pp)))
this.Left = Screen.AllScreens[0].Bounds.Width - this.Width;
else if (this.Left == Screen.AllScreens[0].Bounds.Width - this.Width && !(Win32API.PtInRect(ref Rects, pp)))
this.Left = Screen.AllScreens[0].Bounds.Width - 5;
}