zoukankan
html css js c++ java
winform中的Balloon提示
1.扩展类库
namespace
DvsCC
{
using
System;
using
System.Drawing;
using
System.Reflection;
using
System.Runtime.InteropServices;
using
System.Windows.Forms;
/**/
///
<summary>
///
Summary description for NativeMethods.
///
</summary>
public
class
NativeMethods
{
private
const
long
WS_POPUP
=
0x80000000
;
private
const
long
TTS_BALLOON
=
0x40
;
private
const
long
TTS_NOFADE
=
0x20
;
private
const
int
GWL_STYLE
=
-
16
;
private
const
int
WM_USER
=
0x0400
;
private
const
int
TTM_SETTIPBKCOLOR
=
WM_USER
+
19
;
private
NativeMethods()
{}
public
static
void
SetBalloonStyle ( ToolTip toolTip )
{
NativeWindow window
=
GetNativeWindow ( toolTip );
NativeMethods.SetWindowLong ( window.Handle, GWL_STYLE , WS_POPUP
|
TTS_BALLOON
|
TTS_NOFADE );
}
public
static
void
SetBackColor ( ToolTip toolTip, Color color )
{
int
backColor
=
ColorTranslator.ToWin32( color );
NativeWindow window
=
GetNativeWindow ( toolTip );
//
setting back color
SendMessage( window.Handle, TTM_SETTIPBKCOLOR, backColor,
0
);
}
private
static
NativeWindow GetNativeWindow ( ToolTip toolTip )
{
FieldInfo windowField
=
toolTip.GetType().GetField(
"
window
"
, BindingFlags.NonPublic
|
BindingFlags.Static
|
BindingFlags.Instance );
NativeWindow window
=
(NativeWindow)windowField.GetValue ( toolTip );
if
( window.Handle
==
IntPtr.Zero )
throw
new
ArgumentNullException (
"
window handle is not crated.
"
);
return
window;
}
[DllImport(
"
user32.dll
"
)]
private
static
extern
long
SetWindowLong(IntPtr hwnd,
int
index,
long
val);
[DllImport(
"
user32.dll
"
)]
private
static
extern
int
SendMessage( IntPtr hwnd,
int
msg,
int
wParam,
int
lParam);
}
}
2.使用方法
NativeMethods.SetBalloonStyle ( toolTip1 );
作者:
jillzhang
出处:
http://jillzhang.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
查看全文
相关阅读:
linux磁盘挂载
3个方法解决百度网盘限速 (2018-07-20)
mysql状态分析之show global status
Cgroups子系统介绍
Go语言 关键字:defer
Go语言 map的实现
Go语言 基本类型
MySQL 监控指标
sshpass的使用方法
C++11 std::ref使用场景
原文地址:https://www.cnblogs.com/jillzhang/p/664657.html
最新文章
一码学程 10284 排队找bug 题解 单调队列 或者 线段树RMQ
node.js使用markdown-it批量转md内容为html
用于抓取vijos所有题目信息的node.js脚本
node.js生成验证码及图片
[转]git登录账号密码错误remote: Incorrect username or password
ubuntu下vs code配置c++
推荐一款好用的 office word 的markdown插件
POJ 2584 T-Shirt Gumbo 二分图的多重匹配
POJ 1274 The Perfect Stall 二分图最大匹配
HDU1237 简单计算器 栈
热门文章
[转]Xmind 8 pro 软件破解版
C++高精度整数加减乘除模板
背包(01背包、完全背包、多重背包)代码模板
POJ 3903 Stock Exchange 最长上升子序列入门题
C语言中结构体的构造函数
Codeforces Round #556 (Div. 2) D. Three Religions 题解 动态规划
【KMP】POJ 2185 Milking Grid -- Next函数的应用
[转]Microsoft VS Code 改变默认文字编码
[转]Office 安装卸载太麻烦?用这个工具帮你解决:Office Tool Plus
kubernetes使用中遇到的坑
Copyright © 2011-2022 走看看