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 ...
随机推荐
- PHP基础(一)--字符串函数大盘点(基础篇)
参考地址http://php.net/manual/zh/ref.strings.php addcslashes - 以 C 语言风格使用反斜线转义字符串中的字符 string addcslas ...
- Android Gradle 自定义Task 详解
转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/76408024 本文出自[赵彦军的博客] 一:Gradle 是什么 Gradle是一 ...
- java之SpringMVC配置!配置!配置!
工欲善其事,必先利其器,要想使用SpringMVC自然要先把配置文件写好. 1.web.xml文件 新建web项目之后webRoot目录下面会有一个web.xml文件,我们先来对其进行配置. < ...
- MVC5 框架 配置 盘古分词
2018.5.10日记 1.将sql数据库的内容添加到索引库中, public static readonly IndexManager instance; //静态构造函数,CLR只执行一次 sta ...
- (五)SpringBoot2.0基础篇- Mybatis与插件生成代码
SpringBoot与Mybatis合并 一.创建SpringBoot项目,引入相关依赖包: <?xml version="1.0" encoding="UTF-8 ...
- node.js,express入门看详细篇
先最简单的代码 安装 npm install express app.js 代码内容 const express = require('express') const app = express() ...
- python中@classmethod @staticmethod区别
Python中3种方式定义类方法, 常规方式, @classmethod修饰方式, @staticmethod修饰方式. class A(object): def foo(self, x): prin ...
- 夜神模拟器链接Android studoid
在cmd 窗口输入:adb.exe connect 127.0.0.1:62001然后as就自动匹配了夜神经常忘记,特此提醒
- 并发库应用之六 & 有条件阻塞Condition应用
Condition的功能类似在传统线程技术中的 Object.wait() 和 Object.natify() 的功能,传统线程技术实现的互斥只能一个线程单独干,不能说这个线程干完了通知另一个线程来干 ...
- jsp页面日期格式不正确
第一种: 如果是从数据库获取的时间(数据库中日期格式是乱的)可以在数据库取数据时 进行格式化 例如 ;TO_CHAR(SYSDATE,'YYYY-MM-DD') 第二种: 在数据库取出数据后 ...