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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
查看全文
相关阅读:
2019-9-2-C#命令行解析工具
2018-9-20-断点调试-Windows-源代码
2018-9-20-断点调试-Windows-源代码
2018-8-10-dot-net-core-使用-IPC-进程通信
2018-8-10-dot-net-core-使用-IPC-进程通信
Java实现 LeetCode 592 分数加减运算(纯体力活)
Java实现 LeetCode 590 N叉树的后序遍历(遍历树,迭代法)
Java实现 LeetCode 590 N叉树的后序遍历(遍历树,迭代法)
Java实现 LeetCode 590 N叉树的后序遍历(遍历树,迭代法)
Java实现 LeetCode 589 N叉树的前序遍历(遍历树)
原文地址:https://www.cnblogs.com/jillzhang/p/664657.html
最新文章
前端碎语(1)
用纯CSS实现优雅的tab页
JavaScript作用域链与闭包的理解
Material Design Lite,简洁惊艳的前端工具箱。
html5知识点补充—footer元素的使用
html5知识点补充—mark元素的使用
gulp详细基础教程
块级元素和行内元素的区别
每日算法之三十四:Multiply Strings
[Oracle] Merge语句
热门文章
【C/C++多线程编程之七】pthread信号量
Openck_Swift源代码分析——添加、删除设备时算法详细的实现过程
智能家电缘何“叫好不叫座”?
shell 中数组学习
项目ITP(七) javaWeb 整合 Quartz 实现动态调度 而且 持久化
统计选中的复选框的个数
freemarker写select组件(一)
OpenCV灰度化图像
51nod1327 棋盘游戏
2019-9-2-C#命令行解析工具
Copyright © 2011-2022 走看看