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 ...
随机推荐
- ScrollView的顶部下拉和底部上拉回弹效果
要实现ScrollView的回弹效果,需要对其进行触摸事件处理.先来看一下简单的效果: 根据Android的View事件分发处理机制,下面对dispatchTouchEvent进行详细分析: 在加载布 ...
- 使用LSTM和Softmx来进行意图识别
前言 在前面我们大致介绍了什么是意图识别,把这个问题抽象出来其实是一个分类问题.在结构上面,我们使用LSTM来提取特征,Softmax来进行最后的多分类.由于语料的限制,我们目前仅考虑电台,音乐,问答 ...
- HDU-1017
A Mathematical Curiosity Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- HDU-5706
GirlCat Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem Desc ...
- 163邮箱 SMTP发送邮件注意点
在之前163邮箱注册的时候默认开通SMTP服务的,之后需要自己手动开始. 在配置的时候服务器的地址固定 用户名称就是你的邮箱 密码需要注意的是有的是你邮箱的密码,如果不对需要填写你的授权码!
- Maven的使用
在项目中,我们通常会为项目添加多种多样的依赖包(jar包),去网上下载,然后引入到项目中,很是麻烦. 但是用maven后,这一切都将变得简单起来.由于我的MyEclipse已经集成了maven插件,这 ...
- phone number
problem description: you should change the given digits string into possible letter string according ...
- java基础语法3
逻辑运算符 &:与,和有共同的,必须条件都满足才是true 有false就返回false,必须都是true才返回true |:或者,其中有一个满足条件就返回true ^亦或,相同是false, ...
- C/C++静态代码安全检查工具
静态代码安全检查工具是一种能够帮助程序员自动检测出源程序中是否存在安全缺陷的软件.它通过逐行分析程序的源代码,发现软件中潜在的安全漏洞.本文针对 C/C++语言程序设计中容易存在的多种安全问题,分别分 ...
- python!!!!惊了,这世上居然还有这么神奇的东西存在
第一次接触到python的时候实在看学习3Blue1Brown的视频线性代数的本质的时候.惊奇的是里面的视频操作,例如向量的变化,线性变换等都是由python用代码打出来的.那时的我只是以为pytho ...