惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
量子位
N
Netflix TechBlog - Medium
M
MIT News - Artificial intelligence
GbyAI
GbyAI
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
Y
Y Combinator Blog
L
LangChain Blog
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
Martin Fowler
Martin Fowler
aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客

博客园 - XiaoK

在centOS linux上使用chrony搭建NTP时间同步服务器 centOS端口映射命令 java gc日志的基本知识 定时清除linux内存buff/cache缓存 将libstdc++.so.6升级到libstdc++.so.6.0.29 修改rabbitMQ3.8默认端口号 一个项目用的linunx后台服务配置 nginx负载均衡的配置 linux配置nginx开机启动 vi编辑器常用命令 解决setroubleshootd进程占用内存、cpu高 centOS linux常用操作命令 Internet Explorer 安全区域注册表项说明 获取WPF控件句柄的方法 当远程访问mysql时,mysql会解析域名,会导致访问速度很慢 [转]c#消息处理 c#实现渐变色 OpenFileDialog组件会更改应用程序默认目录问题 winForm中将控件背景设为透明色
创建鼠标指针图标
XiaoK · 2009-04-16 · via 博客园 - XiaoK

using System.Runtime.InteropServices;
private struct IconInfo
{
    public bool fIcon;
    public Int32 xHotspot;
    public Int32 yHotspot;
    public IntPtr hbmMask;
    public IntPtr hbmColor;        
}

[DllImport("user32.dll")]
private static extern IntPtr CreateIconIndirect(ref IconInfo iconInfo);

public Cursor RectCursor(Color AForeColor, Color ATransparent, int ASize)
{
    if (ASize <= 0) return null;
    Bitmap vBitmap = new Bitmap(32, 32,
        System.Drawing.Imaging.PixelFormat.Format24bppRgb);
    Graphics vGraphics = Graphics.FromImage(vBitmap);
    vGraphics.FillRectangle(new SolidBrush(ATransparent), 0, 0, 32, 32);
    vGraphics.FillRectangle(new SolidBrush(AForeColor), 0, 0, ASize, ASize);
    vGraphics.Dispose();
    vBitmap.MakeTransparent(ATransparent);

    IconInfo vIconInfo = new IconInfo();
    vIconInfo.fIcon = false;
    vIconInfo.xHotspot = ASize / 2;
    vIconInfo.yHotspot = ASize / 2;
    vIconInfo.hbmMask = vBitmap.GetHbitmap();
    vIconInfo.hbmColor = vBitmap.GetHbitmap();
    IntPtr vHandle = CreateIconIndirect(ref vIconInfo);
    return new Cursor(vHandle);
}

private void button1_Click(object sender, EventArgs e)
{
    Cursor = RectCursor(Color.Red, Color.Black, 16);
}