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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
查看全文
相关阅读:
【BZOJ 2916】 2916: [Poi1997]Monochromatic Triangles (容斥)
【BZOJ 2024】 2024: [SHOI2009] 舞会 (容斥原理+高精度)
【BZOJ 3235】 3235: [Ahoi2013]好方的蛇 (单调栈+容斥原理)
【BZOJ 4710】 4710: [Jsoi2011]分特产 (容斥原理)
【BZOJ 1853】 1853: [Scoi2010]幸运数字 (容斥原理)
【BZOJ 3812】 3812: 主旋律 (容斥原理**)
【BZOJ 2839】 2839: 集合计数 (容斥原理)
POJ2635——The Embarrassed Cryptographer(高精度取模+筛选取素数)
POJ2533——Longest Ordered Subsequence(简单的DP)
POJ2531——Network Saboteur(随机化算法水一发)
原文地址:https://www.cnblogs.com/jillzhang/p/664657.html
最新文章
曙光服务器挂载EMC存储
linux 启动流程
linux 系统管理学习
linux网络学习
做到让DBCP连接池不超时
suse下修改主机名
部署eclipse项目到tomcat
【Codeforces 498B】 B. Name That Tune (概率DP)
【CF540D】 D. Bad Luck Island (概率DP)
【CF398B】B. Painting The Wall(期望)
热门文章
【CF 453A】 A. Little Pony and Expected Maximum(期望、快速幂)
【CF148D】 Bag of mice (概率DP)
【BZOJ 2688】 2688: Green Hackenbush (概率DP+博弈-树上删边)
【BZOJ 1419】1419: Red is good (概率DP)
【BZOJ 3640】JC的小苹果 (高斯消元,概率DP)
【BZOJ 4558】 4558: [JLoi2016]方 (计数、容斥原理)
【BZOJ 2986】 莫比乌斯函数+容斥原理
【CF 585E】 E. Present for Vitalik the Philatelist
【BZOJ 4455】 4455: [Zjoi2016]小星星 (容斥原理+树形DP)
【BZOJ 4361】 4361: isn (DP+树状数组+容斥)
Copyright © 2011-2022 走看看