c# winform tooltip显示问题

toliyuequn126com 2012-05-26 10:27:47
win7 32位 旗舰版下 tooltip背景色无效 求解释。
...全文
689 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
风之影子 2012-05-27
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.tooltip.ownerdraw(v=vs.80).aspx
风之影子 2012-05-27
  • 打赏
  • 举报
回复
早上在解决这个问题的时候,也在想微软当时为什么不定义属性来进行切换,必须要自己绘制。

细看后才发现,微软在MSDN上对此控件类的备注里有一句话如下:

通常,ToolTip 由操作系统绘制,但是若要自定义 ToolTip 的外观,可将 OwnerDraw 属性设置为 true 并处理 Draw 事件。
风之影子 2012-05-27
  • 打赏
  • 举报
回复
首先设置tooltip控件的OwnerDraw属性为True(由用户自己来绘制,不使用系统绘制)
然后在tooltip的Draw事件下加入自绘制代码,下面五行

Graphics g = e.Graphics;
g.FillRectangle(new SolidBrush(this.toolTip1.BackColor), g.ClipBounds);
e.Graphics.DrawLines(SystemPens.ControlLightLight, new Point[] { new Point(0, e.Bounds.Height - 1), new Point(0, 0), new Point(e.Bounds.Width - 1, 0) });
e.Graphics.DrawLines(SystemPens.ControlDarkDark, new Point[] { new Point(0, e.Bounds.Height - 1), new Point(e.Bounds.Width - 1, e.Bounds.Height - 1), new Point(e.Bounds.Width - 1, 0) });
TextFormatFlags sf = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.NoFullWidthCharacterBreak;
e.DrawText(sf);
toliyuequn126com 2012-05-26
  • 打赏
  • 举报
回复
将win7的视觉效果中的 在窗口和按钮上显示视觉效果 选项去掉就好了 ! 但是这样win7 的界面就难看了! 求较好的解决方案 ! 难道要用自定义 tooltip
toliyuequn126com 2012-05-26
  • 打赏
  • 举报
回复
在窗口和按钮上使用视觉样式后 tooltip背景色就无效了!
真是让人蛋疼啊。

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧