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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
查看全文
相关阅读:
问题账户需求分析
需求分析初学理解
GitHub初步探索-1-使用本地代码管理工具,简化上传的过程
软件工程概论-个人总结
第二次冲刺-个人工作总结05
第二次冲刺-个人工作总结04
第二次冲刺-个人工作总结03
第二次冲刺-个人工作总结02
第二次冲刺-个人工作总结01
第一次冲刺-个人工作总结10
原文地址:https://www.cnblogs.com/jillzhang/p/664657.html
最新文章
python字典的增删改查
python scoket 设置协议TCP_NODELAY关闭,设置接受延时。
tomcat 启动失败,解决办法之一
hibernate DetachedCriteria 子查询对应sql的in语句
Python with语句
beautifulsoup 根据class属性查找标签的方法。
scoketServer 多线程同步
jsp页面相对路径配置 String path = request.getContextPath();
spring MVC js和加载不出图片和js等静态文件的问题。
成功搭建 spring + mybatis + spring MVC
热门文章
hello world
13-javascript-创建对象的几种常用方式
javascript----定时器
js中this 对象
计算机基础----计算机硬件发展史
计算机基础系列1----硬件
网络基础之--操作系统
网络基础之----网络协议
网络基础之---子网划分
python 并发编程之---I/O模型
Copyright © 2011-2022 走看看