bcb里,如何模拟hint提示框,在某区域鼠标停留一段时间出现自定义的信息框

gentlezhou 2010-04-04 02:12:40
像提示框一样,鼠标停留一段时间出现自定义的信息框(可能是panel、image等控件构成)

例如:现在有一张图片用TImage加载。我想在区域A显示信息框a,在区域B显示信息框b。前提是停留在该区域几秒后才弹出信息框。

怎么实现?
...全文
584 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
malhoteras 2010-09-17
  • 打赏
  • 举报
回复
I can see that you are putting 1z0-051 a lot of time and effort into your blog and detailed articles! I am deeply in love with every 220-701 single piece of information you post here. Will be back often 350-001 to read more updates in future 220-702 as well.my best wishes for you always so keep it up.regards
nomzz333 2010-04-16
  • 打赏
  • 举报
回复
There are certainly different posts at here,but i didnt find any post related to projects like san francisco condos , paris hotel...if someone have information about it,do tell me!Well any updates related to this post?if yes than do tell me!actually i came here while surfing net to get data related to projects of virginia beach vacation packages and find this post different one...Is there anyone having information about disney cruise?if yes than do tell me!any updates?if yes than do tell me!This one seems to me different type of post...one who dont know about it before may get useful information from this post...well i wanna say that The way how you tried to explain some posts at here seems to me different...




gentlezhou 2010-04-12
  • 打赏
  • 举报
回复
原来是继承THintWindow啊~~
结贴吧
YeBinYe 2010-04-04
  • 打赏
  • 举报
回复
在老妖面前"班门弄斧"一下,将他的代码贴出来

// 自定义 THintWindow 类
class TCcrunHintWindow : public THintWindow
{
bool FActivating;
__fastcall TCcrunHintWindow(TComponent* Owner)
: THintWindow(Owner)
{
Canvas->Font->Name = "宋体";
Canvas->Font->Color = clBlack;
Canvas->Font->Size = 9;
}
void __fastcall Paint(void)
{
TRect rect = ClientRect;
// Hint边框颜色
Canvas->Brush->Color = TColor(0xDBB8BA);
Canvas->FillRect(rect);
// 绘制整个Hint的边框
Canvas->Pen->Color = TColor(0x69230E);
Canvas->Rectangle(rect);
// Hint背景的颜色
Color = clWhite;
// Hint文字透明
Canvas->Brush->Style = bsClear;
// 绘出Hint文字
Canvas->Font->Color = clBlack;
Canvas->TextOut(4, int(rect.Bottom / 2)
- int(Canvas->TextHeight(Caption) / 2), Caption);
}
virtual void __fastcall NCPaint(HDC hdc)
{
// 63 63 72 75 6E 2E 63 6F 6D
Invalidate();
}
virtual void __fastcall CreateParams(TCreateParams ¶ms)
{
// 去掉Hint窗口的边框
Params.Style = Params.Style & ~WS_BORDER;
THintWindow::CreateParams(Params);
}
// Code by ccrun(老妖),做人要厚道,转载请留名
virtual void __fastcall ActivateHint(const TRect &Rect, const String AHint)
{
FActivating = true;
try
{
// 本文转自 C++Builder研究 - http://www.ccrun.com/article.asp?i=642&d=u7p4j5
Caption = AHint;
TRect r = Rect;
r.Left -= 10;
r.Right += 10;
r.Top -= 5;
r.Bottom += 5;

// 更新区域
UpdateBoundsRect(r);
// Hint窗口处于屏幕边缘时的调整
if(r.Top + Height > Screen->DesktopHeight)
r.Top = Screen->DesktopHeight - Height;
if(r.Left + Width > Screen->DesktopWidth)
r.Left = Screen->DesktopWidth - Width;
if(r.Left < Screen->DesktopLeft)
r.Left = Screen->DesktopLeft;
if(r.Bottom < Screen->DesktopTop)
r.Bottom = Screen->DesktopTop;
// 创建一个矩形
// 63 63 72 75 6E 2E 63 6F 6D
HRGN hrgn = CreateRectRgn(0, 0, r.Width(), r.Height());
// HRGN hrgn = CreateRoundRectRgn(0, 0, r.Width(), r.Height(), 4, 4);
// 设置指定句柄的窗口形状
SetWindowRgn(Handle, hrgn, true);
// 改变窗口的位置,Z Order,及其他一些属性
SetWindowPos(Handle, HWND_TOPMOST, r.Left, r.Top, r.Width(),
r.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE);
// 重画窗口
Invalidate();
}
__finally
{
FActivating = false;
}
}
};
//---------------------------------------------------------------------------
// 实现代码
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
HintWindowClass = __classid(TCcrunHintWindow);
//
ShowHint = true;
Button1->Hint = "这是一个按钮";
Edit1->Hint = "这是一个文本框";
}
new_BCBER 2010-04-04
  • 打赏
  • 举报
回复
有困难找老妖啊
http://www.ccrun.com/article.asp?i=642&d=u7p4j5
gentlezhou 2010-04-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jjwwang 的回复:]
hittest消息,
gettickcount-gettickcount>1000(1t)
[/Quote]
WM_NCHITTEST,这消息不太了解。能说下吗?
经过TImage控件上方也能发出这个消息吗?
还有gettickcount是什么时候开始?该不会是一直get吧?如果程序不晕,我也可能早晕了。

另外我看到有些控件在Events里有CustomHint,不知道这个怎么用?有知道的说下
gentlezhou 2010-04-04
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 1cctv 的回复:]
无需模拟,bcb中每个控制都自带hint提示框的。
[/Quote]
我是要显示自定义的信息框,就它原有的只能写字符串而已。
1cctv 2010-04-04
  • 打赏
  • 举报
回复
无需模拟,bcb中每个控制都自带hint提示框的。
CACACACACA 2010-04-04
  • 打赏
  • 举报
回复
hittest消息,
gettickcount-gettickcount>1000(1t)

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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