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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
查看全文
相关阅读:
把数组排成最小的数
整数中1出现的次数
连续子数组的最大和
快速排序
penCV入门
OpenCV视频操作
linux下导入oracle数据表
js工作备注
oracle创建默认表空间---重要
oracle的导入导出
原文地址:https://www.cnblogs.com/jillzhang/p/664657.html
最新文章
Rust 学习之基于 RefCell 的简单二叉树
Rust 学习之 mod
Mac 上 vscode 的 rust-analyzer 扩展无法追踪/跟踪方法定义
【译】数据库基础:用 Go 从零开始写一个 SQL 数据库 —— 第二部分
现代浏览器中input提示禁用
【译】Rust 的 Result 类型入门
【译】使用 Rust 构建你自己的 Shell
如何可以发布一个日期在6月份的博客园日志?
一个造成内存溢出的代码
虚拟机Virtualbox网络设置HostOnly模式连接外网配置CentOS7的阿里云yum源
热门文章
新装plsql developer使用配置
group by与sum一起进行数据统计
PLSQL编程开发-02
PLSQL编程开发-01
一些比较好听的音乐
codeblocks使用操作
第一个只出现一次的字符
二叉树的直径
二叉树的深度
丑数
Copyright © 2011-2022 走看看