CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  控件

如何使使用了SetCapture的控件显示tooltiptext?

楼主lingll(blog.csdn.net/lingll/)2002-07-30 18:16:08 在 VB / 控件 提问

或者有没有办法强制显示tooltiptext,就是说有没有办法做出tooltiptext的效果,无论鼠标在什么地方  
   
  两个问题解决任意一个都给分 问题点数:100、回复次数:7Top

1 楼zyl910(编程的乐趣在于编程控制硬件,与用图形学实现绚丽效果)回复于 2002-07-30 19:18:19 得分 10

自己做个Form  
  用来模拟ToolTip  
   
  最好用“ShowWindow   hWnd,   SW_SHOWNOACTIVATE”方式显示窗体  
  这样就不会影响当前窗体Top

2 楼YHeng(我来也!!!!!!)回复于 2002-07-30 19:25:46 得分 10

创建一个Tooltip的类,然后就可以使用喽!!!!!!Top

3 楼lingll(blog.csdn.net/lingll/)回复于 2002-07-30 23:12:40 得分 0

用form模拟,这个方法可以,不过就是较繁  
   
     
  tooltip类是什么?如何创建(自己写?),能明白些吗?Top

4 楼shawls(VB Fan)(QQ:9181729)回复于 2002-07-31 01:22:19 得分 80

气泡提示框(ToolTip)上  
   
  Option   Explicit  
  Private   Declare   Function   CreateWindowEx   Lib   "User32"   Alias   "CreateWindowExA"   (ByVal   dwExStyle   As   Long,   ByVal   lpClassName   As   String,   ByVal   lpWindowName   As   String,   ByVal   dwStyle   As   Long,   ByVal   X   As   Long,   ByVal   Y   As   Long,   ByVal   nWidth   As   Long,   ByVal   nHeight   As   Long,   ByVal   hWndParent   As   Long,   ByVal   hMenu   As   Long,   ByVal   hInstance   As   Long,   lpParam   As   Any)   As   Long  
  Private   Declare   Function   SendMessageAny   Lib   "User32"   Alias   "SendMessageA"   (ByVal   hWnd   As   Long,   ByVal   wMsg   As   Long,   ByVal   wParam   As   Long,   lParam   As   Any)   As   Long  
  Private   Declare   Function   DestroyWindow   Lib   "User32"   (ByVal   hWnd   As   Long)   As   Long  
  Private   Declare   Function   GetClientRect   Lib   "User32"   (ByVal   hWnd   As   Long,   lpRect   As   RECT)   As   Long  
   
  Private   Const   WM_USER   =   &H400  
  Private   Const   CW_USEDEFAULT   =   &H80000000  
  Private   Const   SWP_NOSIZE   =   &H1  
  Private   Const   SWP_NOACTIVATE   =   &H10  
  Private   Const   SWP_NOMOVE   =   &H2  
  Private   Const   HWND_TOPMOST   =   -1  
   
  Private   Type   RECT  
          Left   As   Long  
          Top   As   Long  
          Right   As   Long  
          Bottom   As   Long  
  End   Type  
   
  Private   Const   TTS_NOPREFIX   =   &H2  
  Private   Const   TTF_TRANSPARENT   =   &H100  
  Private   Const   TTF_CENTERTIP   =   &H2  
  Private   Const   TTM_ADDTOOLA   =   (WM_USER   +   4)  
  Private   Const   TTM_ACTIVATE   =   WM_USER   +   1  
  Private   Const   TTM_UPDATETIPTEXTA   =   (WM_USER   +   12)  
  Private   Const   TTM_SETMAXTIPWIDTH   =   (WM_USER   +   24)  
  Private   Const   TTM_SETTIPBKCOLOR   =   (WM_USER   +   19)  
  Private   Const   TTM_SETTIPTEXTCOLOR   =   (WM_USER   +   20)  
  Private   Const   TTM_SETTITLE   =   (WM_USER   +   32)  
  Private   Const   TTS_BALLOON   =   &H40  
  Private   Const   TTS_ALWAYSTIP   =   &H1  
  Private   Const   TTF_SUBCLASS   =   &H10  
  Private   Const   TOOLTIPS_CLASSA   =   "tooltips_class32"  
   
  Private   Type   TOOLINFO  
          lSize   As   Long  
          lFlags   As   Long  
          lHwnd   As   Long  
          lId   As   Long  
          lpRect   As   RECT  
          hInstance   As   Long  
          lpStr   As   String  
          lParam   As   Long  
  End   Type  
   
  Private   mvarBackColor   As   Long   'local   copy  
  Private   mvarTitle   As   String   'local   copy  
  Private   mvarForeColor   As   Long   'local   copy  
  Private   mvarParentControl   As   Object   'local   copy  
  Private   mvarIcon   As   ttIconType   'local   copy  
  Private   mvarCentered   As   Boolean   'local   copy  
  Private   mvarStyle   As   ttStyleEnum     'local   copy  
  Private   mvarTipText   As   String  
   
  Public   Enum   ttIconType  
          TTNoIcon   =   0  
          TTIconInfo   =   1  
          TTIconWarning   =   2  
          TTIconError   =   3  
  End   Enum  
   
  Public   Enum   ttStyleEnum  
          TTStandard  
          TTBalloon  
  End   Enum  
   
  Private   lHwnd   As   Long  
  Private   Ti   As   TOOLINFO  
   
  Public   Property   Let   Style(ByVal   vData   As   ttStyleEnum)  
          mvarStyle   =   vData  
  End   Property  
   
  Public   Property   Get   Style()   As   ttStyleEnum  
          Style   =   mvarStyle  
  End   Property  
   
  Public   Property   Let   Centered(ByVal   vData   As   Boolean)  
  'used   when   assigning   a   value   to   the   property,   on   the   left   side   of   an   assignment.  
  'Syntax:   X.Centered   =   5  
          mvarCentered   =   vData  
  End   Property  
   
  Public   Property   Get   Centered()   As   Boolean  
  'used   when   retrieving   value   of   a   property,   on   the   right   side   of   an   assignment.  
  'Syntax:   Debug.Print   X.Centered  
          Centered   =   mvarCentered  
  End   Property  
   
   
   
   
                以上代码来自:   SourceCode   Explorer(源代码数据库)  
                        复制时间:   2002-07-31   01:17:25  
                        当前版本:   1.0.720  
                        软件作者:   Shawls  
                        个人主页:   Http://Shawls.Yeah.Net  
                            E-Mail:   ShawFile@163.Net  
                                    QQ:   9181729  
  气泡提示框(ToolTip)中  
   
  Public   Function   Create()   As   Boolean  
          Dim   lpRect   As   RECT  
          Dim   lWinStyle   As   Long  
           
          If   lHwnd   <>   0   Then  
                  DestroyWindow   lHwnd  
          End   If  
           
          lWinStyle   =   TTS_ALWAYSTIP   Or   TTS_NOPREFIX  
           
          ''create   baloon   style   if   desired  
          If   mvarStyle   =   TTBalloon   Then   lWinStyle   =   lWinStyle   Or   TTS_BALLOON  
           
          ''the   parent   control   has   to   have   been   set   first  
          If   Not   mvarParentControl   Is   Nothing   Then  
                  lHwnd   =   CreateWindowEx(0&,   _  
                                          TOOLTIPS_CLASSA,   _  
                                          vbNullString,   _  
                                          lWinStyle,   _  
                                          CW_USEDEFAULT,   _  
                                          CW_USEDEFAULT,   _  
                                          CW_USEDEFAULT,   _  
                                          CW_USEDEFAULT,   _  
                                          mvarParentControl.hWnd,   _  
                                          0&,   _  
                                          App.hInstance,   _  
                                          0&)  
                                           
                  ''make   our   tooltip   window   a   topmost   window  
                  SetWindowPos   lHwnd,   _  
                          HWND_TOPMOST,   _  
                          0&,   _  
                          0&,   _  
                          0&,   _  
                          0&,   _  
                          SWP_NOACTIVATE   Or   SWP_NOSIZE   Or   SWP_NOMOVE  
                                           
                  ''get   the   rect   of   the   parent   control  
                  GetClientRect   mvarParentControl.hWnd,   lpRect  
                   
                  ''now   set   our   tooltip   info   structure  
                  With   Ti  
                          ''if   we   want   it   centered,   then   set   that   flag  
                          If   mvarCentered   Then  
                                  .lFlags   =   TTF_SUBCLASS   Or   TTF_CENTERTIP  
                          Else  
                                  .lFlags   =   TTF_SUBCLASS  
                          End   If  
                           
                          ''set   the   hwnd   prop   to   our   parent   control's   hwnd  
                          .lHwnd   =   mvarParentControl.hWnd  
                          .lId   =   0  
                          .hInstance   =   App.hInstance  
                          '.lpstr   =   ALREADY   SET  
                          .lpRect   =   lpRect  
                  End   With  
                   
                  ''add   the   tooltip   structure  
                  SendMessageAny   lHwnd,   TTM_ADDTOOLA,   0&,   Ti  
                   
                  ''if   we   want   a   title   or   we   want   an   icon  
                  If   mvarTitle   <>   vbNullString   Or   mvarIcon   <>   TTNoIcon   Then  
                          SendMessageAny   lHwnd,   TTM_SETTITLE,   CLng(mvarIcon),   ByVal   mvarTitle  
                  End   If  
                   
                  If   mvarForeColor   <>   Empty   Then  
                          SendMessageAny   lHwnd,   TTM_SETTIPTEXTCOLOR,   mvarForeColor,   0&  
                  End   If  
                   
                  If   mvarBackColor   <>   Empty   Then  
                          SendMessageAny   lHwnd,   TTM_SETTIPBKCOLOR,   mvarBackColor,   0&  
                  End   If  
                   
          End   If  
  End   Function  
   
  Public   Property   Set   ParentControl(ByVal   vData   As   Object)  
  'used   when   assigning   an   Object   to   the   property,   on   the   left   side   of   a   Set   statement.  
  'Syntax:   Set   x.ParentControl   =   Form1  
          Set   mvarParentControl   =   vData  
  End   Property  
   
  Public   Property   Get   ParentControl()   As   Object  
  'used   when   retrieving   value   of   a   property,   on   the   right   side   of   an   assignment.  
  'Syntax:   Debug.Print   X.ParentControl  
          Set   ParentControl   =   mvarParentControl  
  End   Property  
   
   
   
   
                以上代码来自:   SourceCode   Explorer(源代码数据库)  
                        复制时间:   2002-07-31   01:18:15  
                        当前版本:   1.0.720  
                        软件作者:   Shawls  
                        个人主页:   Http://Shawls.Yeah.Net  
                            E-Mail:   ShawFile@163.Net  
                                    QQ:   9181729Top

5 楼shawls(VB Fan)(QQ:9181729)回复于 2002-07-31 01:27:19 得分 0

气泡提示框(ToolTip)下  
   
  Public   Property   Let   Icon(ByVal   vData   As   ttIconType)  
  'used   when   assigning   a   value   to   the   property,   on   the   left   side   of   an   assignment.  
  'Syntax:   X.Icon   =   5  
          mvarIcon   =   vData  
          If   lHwnd   <>   0   And   mvarTitle   <>   Empty   And   mvarIcon   <>   TTNoIcon   Then  
                  SendMessageAny   lHwnd,   TTM_SETTITLE,   CLng(mvarIcon),   ByVal   mvarTitle  
          End   If  
   
  End   Property  
   
  Public   Property   Get   Icon()   As   ttIconType  
  'used   when   retrieving   value   of   a   property,   on   the   right   side   of   an   assignment.  
  'Syntax:   Debug.Print   X.Icon  
          Icon   =   mvarIcon  
  End   Property  
  Public   Property   Let   ForeColor(ByVal   vData   As   Long)  
  'used   when   assigning   a   value   to   the   property,   on   the   left   side   of   an   assignment.  
  'Syntax:   X.ForeColor   =   5  
          mvarForeColor   =   vData  
          If   lHwnd   <>   0   Then  
                  SendMessageAny   lHwnd,   TTM_SETTIPTEXTCOLOR,   mvarForeColor,   0&  
          End   If  
   
  End   Property  
   
  Public   Property   Get   ForeColor()   As   Long  
  'used   when   retrieving   value   of   a   property,   on   the   right   side   of   an   assignment.  
  'Syntax:   Debug.Print   X.ForeColor  
          ForeColor   =   mvarForeColor  
  End   Property  
   
  Public   Property   Let   Title(ByVal   vData   As   String)  
  'used   when   assigning   a   value   to   the   property,   on   the   left   side   of   an   assignment.  
  'Syntax:   X.Title   =   5  
          mvarTitle   =   vData  
          If   lHwnd   <>   0   And   mvarTitle   <>   Empty   And   mvarIcon   <>   TTNoIcon   Then  
                  SendMessageAny   lHwnd,   TTM_SETTITLE,   CLng(mvarIcon),   ByVal   mvarTitle  
          End   If  
  End   Property  
   
  Public   Property   Get   Title()   As   String  
  'used   when   retrieving   value   of   a   property,   on   the   right   side   of   an   assignment.  
  'Syntax:   Debug.Print   X.Title  
          Title   =   Ti.lpStr  
  End   Property  
   
  Public   Property   Let   BackColor(ByVal   vData   As   Long)  
  'used   when   assigning   a   value   to   the   property,   on   the   left   side   of   an   assignment.  
  'Syntax:   X.BackColor   =   5  
          mvarBackColor   =   vData  
          If   lHwnd   <>   0   Then  
                  SendMessageAny   lHwnd,   TTM_SETTIPBKCOLOR,   mvarBackColor,   0&  
          End   If  
           
  End   Property  
   
  Public   Property   Get   BackColor()   As   Long  
  'used   when   retrieving   value   of   a   property,   on   the   right   side   of   an   assignment.  
  'Syntax:   Debug.Print   X.BackColor  
          BackColor   =   mvarBackColor  
  End   Property  
   
  Public   Property   Let   TipText(ByVal   vData   As   String)  
  'used   when   assigning   a   value   to   the   property,   on   the   left   side   of   an   assignment.  
  'Syntax:   X.TipText   =   5  
          Ti.lpStr   =   vData  
          If   lHwnd   <>   0   Then  
                  SendMessageAny   lHwnd,   TTM_UPDATETIPTEXTA,   0&,   Ti  
          End   If  
           
  End   Property  
   
  Public   Property   Get   TipText()   As   String  
  'used   when   retrieving   value   of   a   property,   on   the   right   side   of   an   assignment.  
  'Syntax:   Debug.Print   X.TipText  
          TipText   =   mvarTipText  
  End   Property  
   
  Private   Sub   Class_Terminate()  
          If   lHwnd   <>   0   Then  
                  DestroyWindow   lHwnd  
          End   If  
  End   Sub  
   
   
   
                以上代码来自:   SourceCode   Explorer(源代码数据库)  
                        复制时间:   2002-07-31   01:22:38  
                        当前版本:   1.0.720  
                        软件作者:   Shawls  
                        个人主页:   Http://Shawls.Yeah.Net  
                            E-Mail:   ShawFile@163.Net  
                                    QQ:   9181729Top

6 楼lingll(blog.csdn.net/lingll/)回复于 2002-07-31 02:24:23 得分 0

太棒了,给分  
  btw,为什么在你的主页上找不到这个源代码?Top

7 楼shawls(VB Fan)(QQ:9181729)回复于 2002-07-31 11:51:55 得分 0

 
   
  没有上传  
   
  Top

相关问题

  • 如何让控件的ToolTipText显示的文字换行?
  • 控件未显示
  • Line控件的ToolTipText问题
  • 控件隐藏及显示
  • ●●● 求一显示控件 ●●●
  • vs.net不能显示控件
  • vs.net不能显示控件
  • vs.net不能显示控件
  • Memo控件显示繁体
  • ocx控件显示问题

关键词

  • .net
  • tts
  • tooltiptext
  • lwinstyle
  • tooltip
  • byval
  • longprivate
  • lhwnd
  • mvarparentcontrol
  • swp

得分解答快速导航

  • 帖主:lingll
  • zyl910
  • YHeng
  • shawls

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo