C#开发实例
c#改变系统鼠标
---------------------------------------------------------------------------------------------------
using System.Runtime.InteropServices;
[DllImport("User32.DLL")]
public static extern bool SetSystemCursor(IntPtr hcur, uint id);
public const uint OCR_NORMAL = 32512;
public const uint OCR_IBEAM = 32513;
[DllImport("User32.DLL")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam,
IntPtr pvParam, uint fWinIni);
public const uint SPI_SETCURSORS = 87;
public const uint SPIF_SENDWININICHANGE = 2;
private void button1_Click(object sender, EventArgs e)
{
//设置
SetSystemCursor(Cursors.WaitCursor.CopyHandle(), OCR_NORMAL);
SetSystemCursor(Cursors.WaitCursor.CopyHandle(), OCR_IBEAM);
//..可以根据情况加
}
private void button2_Click(object sender, EventArgs e)
{
//恢复
SystemParametersInfo(SPI_SETCURSORS, 0, IntPtr.Zero, SPIF_SENDWININICHANGE);
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zswang/archive/2007/03/20/1535309.aspx
------------------------------------------------------------------------------------------------------------
C#鼠标拖动控件改变位置并绘制虚框
-------------------------------------------------------------------------------------------------------------
private Point downPoint;
private Rectangle downRectangle;
private Rectangle lastRectangle;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left) return;
downPoint = e.Location;
downRectangle =
new Rectangle(0, 0, ((Control)sender).Width, pictureBox1.Height);
downRectangle.Offset(((Control)sender).PointToScreen(new Point(0, 0)));
ControlPaint.DrawReversibleFrame(
相关文档:
C#画线控件的应用实例介绍之前我们要明白在C#中没有画线的控件,这里写了一个,大家分享。共有两个控件分别是画横线和画竖线的,关于怎么画斜线有兴趣的可以做一个大家分享。
C#画线控件之横线
using System;
using System.Collections;
using System.ComponentModel; ......
手机音乐播发器里有总文件总时间的统计,在酷狗播放器里找了一下没找到。那我想知道这些歌曲的总时间,该怎么办?
其实很简单,稍稍动动手,就能找到答案!
请参考如下步骤:
第一步,保存播放列表,把里面的歌曲保存到一个你喜欢的名字。
第二步,在播放列表上面点右键,到处播放列表到你找的到的地方。
经测试,最新 ......
属性是类中可以像类的字段一样访问的方法。属性可以为类的字段提供保护,避免字段在对象不知道情况下被修改。C#通过属性来修改,读写或计算私有的字段的值。属性相当于对字段访问的封装。下例子可以清楚说明哟:
class Person
{
......
一、C#预处理器指令入门 #define NET11 //NET11,NET20,(必须放在文件第一行)
using System;
//… …
//… …
//… …
string sBeepType = s.Replace(sKey,"");
#if NET20
int.TryParse(sBeepType,out beepType); //在.net 2.0中才有的方法
#endif
#if ......
//Socket基本编程
//服务端:
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
Thread mythread ;
Socket socket;
// 清理所有正在使用的资源。
protected override void Dispose( bool disposing )
{
try
{
socket.Close();//释放资源
......