C# Vista Command Link Control with Windows Forms
using System;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
using System.ComponentModel;namespace Vista.Controls
{
public class CommandLink : Button
{
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
unsafe static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, void* wParam, void* lParam); const int BS_CENTER = 0x00000300;
const int BS_COMMANDLINK = 0x0000000E;
const int BS_DEFCOMMANDLINK = 0x0000000F; const uint BCM_SETNOTE = 0x00001609;
const uint BCM_GETNOTE = 0x0000160A;
const uint BCM_GETNOTELENGTH = 0x0000160B;
const uint BCM_SETSHIELD = 0x0000160C; public XButton()
{
//this.FlatStyle = FlatStyle.System;
} protected override Size DefaultSize
{
get
{
return new Size(, );
}
} protected override CreateParams CreateParams
{
get
{
CreateParams cParams = base.CreateParams;
cParams.Style |= BS_COMMANDLINK;
return cParams;
}
} private bool _shield = false; [Category("Command Link"),
Description("Gets or sets the shield icon visibility of the command link."),
DefaultValue(false)]
public unsafe bool Shield
{
get
{
return _shield;
}
set
{
_shield = value;
SendMessage(new HandleRef(this, Handle), BCM_SETSHIELD, null, &value);
}
} [Category("Command Link"),
Description("Gets or sets the note text of the command link."),
DefaultValue("")]
public string Note
{
get
{
return GetNoteText();
}
set
{
SetNoteText(value);
}
} private unsafe void SetNoteText(string value)
{
fixed (char* lpStr = value)
{
SendMessage(new HandleRef(this, Handle), BCM_SETNOTE, null, lpStr);
}
} private unsafe string GetNoteText()
{
int dwLength = (int)SendMessage(new HandleRef(this, Handle), BCM_GETNOTELENGTH, null, null) + ;
char* lpStr = stackalloc char[dwLength];
SendMessage(new HandleRef(this, Handle), BCM_GETNOTE, &dwLength, lpStr);
return new string(lpStr);
} }
}
C# Vista Command Link Control with Windows Forms的更多相关文章
- Windows Forms (一)
导读 1.什么是 Windows Forms 2.需要学Windows Forms 么? 3.如何手写一个简单的Windows Forms 程序 4.对上面程序的说明 5.Form 类与Control ...
- Windows Forms编程实战学习:第三章 菜单
第三章 菜单 1,控件和容器 所有的Windows Forms控件都是从System.Windows.Forms.Control类继承的,相关类的层次结构如下图所示: MarshalByRefObje ...
- “FormCRUD.csProj.FormMain.Name”隐藏了继承的成员“System.Windows.Forms.Control.Name”。如果是有意隐藏,请使用关键字 new。
一旦运行就显示:“FormCRUD.csProj.FormMain.Name”隐藏了继承的成员“System.Windows.Forms.Control.Name”.如果是有意隐藏,请使用关键字 ne ...
- System.Windows.Forms.Control : Component, IOleControl, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject....
#region 程序集 System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ...
- System.Windows.Forms.ListView : Control
#region 程序集 System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ...
- System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false
多线程程序中,新创建的线程不能访问UI线程创建的窗口控件,这时如果想要访问窗口的控件,发现无法对其控制. 这时可将窗口构造函数中的CheckForIllegalCrossThreadCalls设置为f ...
- create Context Menu in Windows Forms application using C# z
In this article let us see how to create Context Menu in Windows Forms application using C# Introduc ...
- Wizard Framework:一个自己开发的基于Windows Forms的向导开发框架
最近因项目需要,我自己设计开发了一个基于Windows Forms的向导开发框架,目前我已经将其开源,并发布了一个NuGet安装包.比较囧的一件事是,当我发布了NuGet安装包以后,发现原来已经有一个 ...
- Double Buffering Windows Forms
Double Buffering Windows Forms As much as we would like it not to be the case, graphics can be slow ...
随机推荐
- LindDotNetCore~框架介绍及特色功能(有点springboot的意思)
LindDotNetCore模块介绍 大叔博客 LindDotNetCore相关模块介绍 [x] 全局都是依赖DI [x] 消息队列 [x] NoSql [x] Caching [x] 仓储 [x] ...
- Java错误和异常
Java 异常结构图 在 Java 中,所有的异常都有一个共同的祖先 Throwable(可抛出).Throwable 指定代码中可用异常传播机制通过 Java 应用程序传输的任何问题的共性. Th ...
- HDU-5706
GirlCat Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem Desc ...
- web.config中的configSource
在大型项目中,可能存在第三方类库的配置如:log4.net,AOP框架Unity,WCF等,或是自定义的配置,造成web.config内容过多,不易维护,影响Config初始化. 这时我们可以使用co ...
- flush()清空文件缓存区
# 缓冲区:cpu 一级缓存 二级缓存 三级缓存 import time f =open('2.txt','a+' ,encoding='utf-8') f.write('helloworld\n') ...
- css 选择器【转】
最近在研究jQuery的选择器,大家知道jQuery的选择器和css的选择器非常相似,所以整理一下css选择器: css1-css3提供非常丰富的选择器,但是由于某些选择器被各个浏览器支持的情况不一样 ...
- super()方法的使用
如果在子类中也定义了构造器,既_init_()函数,那么基类的构造器该如何调用呢? 方法一.明确指定 使用一个子类的实例去调用基类的构造器,在子类的构造器中明确的指明调用基类的构造器. class C ...
- SSM-Spring-06:Spring的自动注入autowire的byName和byType
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- di的注入上次讲了一些,这次主要阐述域属性的自动注入 先讲byType方式 看名字就知道是根据类型进行自动注入 ...
- vs2017 x64 ibatis.net 平台调用 Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342 x64
遇到的问题: 1.x86无法调用x64 2.调用ibatis.net的providers.config无法通过节点反射查找Oracle.DataAccess, Version=2.112.1.0, C ...
- 在webpack里使用jquery.mCustomScrollbar插件
malihu-custom-scrollbar-plugin是一个依赖jquery的自定义网页滚动条样式插件 网站:http://manos.malihu.gr/jquery-custom-conte ...