Win7下,ToolTip控件设置了BackColor和ForeColor都无效?

nef1983 2012-05-24 02:23:46
将ToolTip的BackColor设置成红色
在winXp下,显示正常;
在win7下,显示无效,为默认白色
有人知道原因吗?
...全文
414 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
triumphal 2012-09-14
  • 打赏
  • 举报
回复
我也遇到这样的问题,谁能回答一下
关注中
xiaoyawoshishui 2012-08-17
  • 打赏
  • 举报
回复
谢谢,很好,很管用
nef1983 2012-05-24
  • 打赏
  • 举报
回复 1

private void button1_Click(object sender, EventArgs e)
{
tt = new ToolTip();
tt.OwnerDraw = true;
tt.Draw += new DrawToolTipEventHandler(tt_Draw);

tt.BackColor = Color.Red;
tt.ForeColor = Color.Yellow;
tt.Show("hello world!@~~~123456789", button1, button1.Width, 0);
}

void tt_Draw(object sender, DrawToolTipEventArgs e)
{
ToolTip tempTT = (ToolTip)sender;
using (Brush backBrush = new SolidBrush(tempTT.BackColor))
{
e.Graphics.FillRectangle(backBrush, e.Bounds);
e.DrawBorder();
}

using (Brush textBrush = new SolidBrush(tempTT.ForeColor))
{
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
sf.FormatFlags = StringFormatFlags.NoWrap;
sf.Trimming = StringTrimming.None;

e.Graphics.DrawString(e.ToolTipText, e.Font, textBrush, e.Bounds, sf);
}
}


  • 打赏
  • 举报
回复
好像有个窗体样式设置为用户自定义就可以了。
dyjdgwg 2012-05-24
  • 打赏
  • 举报
回复
分享代码啊。
dyjdgwg 2012-05-24
  • 打赏
  • 举报
回复
代码共享吧
nef1983 2012-05-24
  • 打赏
  • 举报
回复
自己解决
要重绘tooltip

PS:散分,有人接没
nef1983 2012-05-24
  • 打赏
  • 举报
回复
没人碰到过吗?
nef1983 2012-05-24
  • 打赏
  • 举报
回复
自己顶起

111,126

社区成员

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

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

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