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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
查看全文
相关阅读:
[LeetCode] 330. Patching Array 数组补丁
[LeetCode] 875. Koko Eating Bananas 可可吃香蕉
[LeetCode] 460. LFU Cache 最近最不常用页面置换缓存器
[LeetCode] 395. Longest Substring with At Least K Repeating Characters 至少有K个重复字符的最长子字符串
[LeetCode] 29. Divide Two Integers 两数相除
[LeetCode] 451. Sort Characters By Frequency 根据字符出现频率排序
[LeetCode] 296. Best Meeting Point 最佳开会地点
[LeetCode] 317. Shortest Distance from All Buildings 建筑物的最短距离
css3动画4
CSS Transform / Transition / Animation 属性的区别
原文地址:https://www.cnblogs.com/jillzhang/p/664657.html
最新文章
使用MUI的日期控件引起的探索——HTML5 input类型date属性
纯CSS下拉菜单(希望对有需要的小伙伴有所帮助)
a标签嵌套a标签在实际项目开发中遇到的坑
Bootstrap轮播如何支持移动端左右滑动
本地调用QQ只需要一句代码
前端能做的一些提升网页速度的方法
火狐扫二维码直接在手机上看网页效果
购物车数字加减按钮HTML+CSS+JS(有需要嫌麻烦的小伙伴拿走不谢)
(八)java运算符
(九)java位运算符
热门文章
(七)java转译字符与连接字符串
(二)Nginx反向代理与负载均衡的实现
(一)Nginx正向代理与反向代理
前端开发模块化规范
(二)Vue常用7个属性
(六)java数据类型
(五)java进制
(四)java基本语法
[LeetCode] Top 100 Liked Questions
[LeetCode] 241. Different Ways to Add Parentheses 添加括号的不同方式
Copyright © 2011-2022 走看看