runxinzhi.com
首页
百度搜索
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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
相关阅读:
PAT 甲级 1057 Stack(树状数组解法)
LeetCode 815 公交路线
201771010123汪慧和《面向对象程序设计JAVA》第六周实验总结
汪慧和201771010123《面向对象程序设计JAVA》第四周实验总结
汪慧和201771010123《面向对象程序设计(Java)》第三周学习总结
201771010123汪慧和《面向对象程序设计Java》第二周学习总结
汪慧和201771010123
201771010119穷吉1
学习进度条201771010119穷吉
穷吉201771010119*
原文地址:https://www.cnblogs.com/jillzhang/p/664657.html
最新文章
李瑞红 201771010111《面向对象程序设计(java)》第一周学习总结
李婷华 201771010113 《面向对象程序设计(java)》 第二周学习总结
李婷华 201771010113 《面向对象程序设计(java)》第一周学习总结
9、主成分分析
R语言:实现雷达图的绘制
R语言—如何安装Github包的解决方法,亲测有效
8、特征选择
7.逻辑回归实践
如何用命令行启动系统各应用,对微服务应用启动多个实例
使用cmd命令行进入到指定的目录
热门文章
6.逻辑回归
5.线性回归算法
LeetCode 924 尽量减少恶意软件的传播
LeetCode 1307 口算难题
PAT 甲级 1068 Find More Coins
LeetCode 793 阶乘函数后K个零
LeetCode 1012 至少有 1 位重复的数字
LeetCode 1095 山脉数组中查找目标值(二分法)
2020系统综合实践 第3次实践作业
LeetCode 面试题56 数组中数字的出现次数
Copyright © 2020-2023
润新知