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(
相关文档:
问:
1.如何在JavaScript访问C#函数?
2.如何在JavaScript访问C#变量?
3.如何在C#中访问JavaScript的已有变量?
4.如何在C#中访问JavaScript函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中;
2、在前台写一个js函数,内容为 ......
c#中基类(父类)中的某方法若想在派生类(子类)中被重写(override),必须将基类中的方法定义为virtual,即虚函数。
若派生类将方法修饰为new,即有意隐藏基类中的方法。
下面看一组代码:
public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}
......
属性是类中可以像类的字段一样访问的方法。属性可以为类的字段提供保护,避免字段在对象不知道情况下被修改。C#通过属性来修改,读写或计算私有的字段的值。属性相当于对字段访问的封装。下例子可以清楚说明哟:
class Person
{
......
1 NameSapce
1 1个namespace里面可以有多个类
2 namespace和cs文件是多对多的关系。
3 调用另一个namespace的声明,可以使用using <namespace> ,然后直接调用类名,或者使用namespace.类名来调用
4 namespace支持别名(alias) using namespace = namespace.classname,如using m ......
//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();//释放资源
......