谁能帮我改一下气泡提示的问题?(25)

  • 主题发起人 主题发起人 新来的菜鸟
  • 开始时间 开始时间

新来的菜鸟

Unregistered / Unconfirmed
GUEST, unregistred user!
我在网上搜索了一个程序,但它是跟随鼠标显示的,我想让它在制定控件上显示,例如在Edit1里显示,我改如何改呢?原代码unit Sherryhint;interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,CommCtrl; type THintWin = class(THintWindow) private FLastActive: THandle; public procedure ActivateHint(Rect:TRect;Const AHint:string);override; end; implementationuses Unit1;{ THintWin } procedure AddTipTool(hWnd: DWORD; IconType: Integer; Title, Text: PChar); const TTS_BALLOON =$0040; TTM_SETTITLE=WM_USER + 32; var hWndTip: DWORD; ToolInfo: TToolInfo; begin hWndTip:=CreateWindow(TOOLTIPS_CLASS, nil, WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP, 0, 0, 0, 0, hWnd, 0, HInstance, nil); if (hWndTip <> 0) then begin ToolInfo.cbSize:=SizeOf(ToolInfo); ToolInfo.uFlags:=TTF_IDISHWND or TTF_SUBCLASS or TTF_TRANSPARENT; ToolInfo.uId:=hWnd; ToolInfo.lpszText:=Text; SendMessage(hWndTip,TTM_ADDTOOL,1,Integer(@ToolInfo)); SendMessage(hWndTip,TTM_SETTITLE,IconType,Integer(Title)); end; InitCommonControls(); end; procedure THintWin.ActivateHint(Rect: TRect; const AHint: string); begininherited; if FLastActive <> WindowFromPoint(Mouse.CursorPos) then AddTipTool(WindowFromPoint(Mouse.CursorPos),1,'提示', PChar(AHint));//Application.Hint)); FLastActive:=WindowFromPoint(Mouse.CursorPos);end; initialization Application.HintPause:=0; Application.ShowHint:=False; HintWindowClass:=THintWin; Application.ShowHint:=True; end.
 
to 枝上柳绵你的我试了一下,但好像也是要把鼠标放上去才显示的,我的想法是当按一个按钮,如果Edit1里面是空的话就在Edit1里产生一个气泡提示他此处不能为空,并不需要把鼠标放上去才显示!麻烦再帮看看如何实现,谢谢!
 
edit1.hint = contenxedit1.hint这样就能气泡提示了
 
那位大哥能帮改成不用放鼠标就能显示提示呢?谢谢
 
就是事件不同而已你完全可以把 mouseenter里面的代码拷出来贴到buttonclick里面撒...
 
to 枝上柳绵我试过了,就算把事件放到buttonclick里,也是再点按钮后要把鼠标放上去才会显示,不然就算按了按钮也不会显示的!
 
那位大哥能帮改成不用放鼠标就能显示提示呢?谢谢
 
那位大哥能帮改成不用放鼠标就能显示提示呢?谢谢
 
Hint本身就是这样的。你做个Form得了。
 
Delphi世界qq群:23981160喜欢d的都来
 
测试通过(也是网上找的东拼西凑的)其实可以做成一个类的,呵呵,但不想麻烦了uses CommCtrl;procedure AddTipTool(hWnd: DWORD; IconType: Integer; Title, Text: PChar);const TTS_BALLOON =$0040; TTM_SETTITLE=WM_USER + 32;var hWndTip: DWORD; ToolInfo: TToolInfo;begin hWndTip:=CreateWindow(TOOLTIPS_CLASS, nil, WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP, 0, 0, 0, 0, hWnd, 0, HInstance, nil); if (hWndTip <> 0) then begin ToolInfo.cbSize:=SizeOf(ToolInfo); ToolInfo.uFlags:=TTF_IDISHWND or TTF_SUBCLASS or TTF_TRANSPARENT; ToolInfo.uId:=hWnd; ToolInfo.lpszText:=Text; SendMessage(hWndTip,TTM_ADDTOOL,1,Integer(@ToolInfo)); SendMessage(hWndTip,TTM_SETTITLE,IconType,Integer(Title)); end; InitCommonControls();end;procedure TForm1.edt1Enter(Sender: TObject);var hintTxt: String;beginhintTxt :='i am 张三';// TEdit(Sender).Hint; AddTipTool(WindowFromPoint(edt1.ClientOrigin),1,'提示', PChar(HintTxt));//Application.Hint));//end;
 
后退
顶部