Posts: 858
Threads: 196
Joined: Apr 2005
How can I to create a tooltip anywhere on the screen?
Posts: 12,075
Threads: 141
Joined: Dec 2002
Once I tried it, using standard tooltip control, but unsuccessfully. Of course, it is possible, but requires more time, or I did something wrong.
Posts: 858
Threads: 196
Joined: Apr 2005
Ok. I will use OnScreenDisplay.
Posts: 858
Threads: 196
Joined: Apr 2005
Posts: 12,075
Threads: 141
Joined: Dec 2002
Function Dialog92
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("Dialog92" &Dialog92 0)) ret
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032000 0x0 4 8 48 14 "Show"
;4 Button 0x54032000 0x0 60 8 48 14 "Hide"
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "*" "" ""
ret
;messages
int-- hwndTT
TOOLINFOW-- ti
sel message
,case WM_INITDIALOG
,hwndTT = CreateWindowEx(WS_EX_TOPMOST TOOLTIPS_CLASS 0 TTS_NOPREFIX|TTS_ALWAYSTIP 0 0 0 0 0 0 0 0)
,ti.cbSize=44
,ti.uFlags = TTF_TRACK
,ti.lpszText="test"
,SendMessage(hwndTT, TTM_ADDTOOL, 0, &ti)
,
,case WM_DESTROY
,DestroyWindow hwndTT
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,SendMessage(hwndTT, TTM_TRACKPOSITION, 0, MakeInt(300, 200))
,SendMessage(hwndTT, TTM_TRACKACTIVATE, 1, &ti)
,
,case 4
,SendMessage(hwndTT, TTM_TRACKACTIVATE, 0, &ti)
,
ret 1
Posts: 858
Threads: 196
Joined: Apr 2005
I test in W2000 and doesn't work.
Posts: 12,075
Threads: 141
Joined: Dec 2002
sizeof(TOOLINFOW) on W2000 is different. Now fixed.
Posts: 858
Threads: 196
Joined: Apr 2005
Thanks.
Is possible BalloonToolTip and multiline?
Posts: 12,075
Threads: 141
Joined: Dec 2002
Balloon - only on XP and later. Add TTS_BALLOON style.
Multiline - SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, 0, 400)
Posts: 858
Threads: 196
Joined: Apr 2005
Thank you very much.
It would be good a function that worked in all windows ...
Posts: 12,075
Threads: 141
Joined: Dec 2002
Function ShowTooltip
;\
function $text timeS x y [maxTipWidth] [flags] [$title] [$titleIcon] ;;flags: 1 balloon (XP+), 2 asynchronous (don't wait). titleIcon: "info" "warning" "error"
;Shows tooltip that is not attached to a control.
;text - text.
;timeS - time to show, s.
;x, y - position in screen.
;maxTipWidth - max width. If nonzero, text can be multiline.
;flags:
;;;1 - balloon. Unavailable on Windows 2000.
;;;2 - don't wait until disappears. The function creates other thread to show the tooltip.
;title - title text. Max 99 characters.
;titleIcon - one of standard icons (see above). On Windows XP SP2 and later can be icon file.
;EXAMPLES
;ShowTooltip "tooltip" 2 100 100
;str s="Asynchronous balloon tooltip[]with title and icon."
;ShowTooltip s 10 xm ym 300 3 "title" "$qm$\info.ico"
if flags&2
,mac "ShowTooltip" "" text timeS x y maxTipWidth flags~2 title titleIcon
,ret
int st=TTS_NOPREFIX|TTS_ALWAYSTIP|TTS_CLOSE
if(flags&1) st|TTS_BALLOON
int hwndTT = CreateWindowEx(WS_EX_TOPMOST TOOLTIPS_CLASS 0 st 0 0 0 0 0 0 0 0)
if(maxTipWidth) SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, 0, maxTipWidth)
if !empty(title)
,int ic; if(!empty(titleIcon)) ic=SelStr(0 titleIcon "info" "warning" "error"); if(!ic) __Hicon _ic=GetFileIcon(titleIcon); ic=_ic
,SendMessage(hwndTT TTM_SETTITLEW ic @title)
TOOLINFOW ti.cbSize=44
ti.uFlags = TTF_TRACK
ti.lpszText=@text
SendMessage(hwndTT, TTM_ADDTOOLW, 0, &ti)
SendMessage(hwndTT, TTM_TRACKPOSITION, 0, MakeInt(x, y))
SendMessage(hwndTT, TTM_TRACKACTIVATE, 1, &ti)
opt waitmsg 1
wait timeS -WV hwndTT; err
DestroyWindow hwndTT
Posts: 858
Threads: 196
Joined: Apr 2005
Posts: 1,006
Threads: 330
Joined: Mar 2007
This is very cool and helpful. Is there a way to trigger the tooltip when the cursor is in a particular location (rect?) on the screen or over a certain element from another application (acc or control ID)
Thanks,
S
Posts: 576
Threads: 97
Joined: Aug 2007
stupomer Wrote:This is very cool and helpful. Is there a way to trigger the tooltip when the cursor is in a particular location (rect?) on the screen or over a certain element from another application (acc or control ID)
Thanks,
S
Don't know if maybe the functions contained in this post can help you..
Couple button questions. Enlarge control on mouse over.
Posts: 12,075
Threads: 141
Joined: Dec 2002
Function tooltip1
;Edit and run this function.
;To edit when already running, end "tooltip1" thread.
SetThreadPriority GetCurrentThread THREAD_PRIORITY_LOWEST
POINT p pp
rep
,0.5
,xm p
,if(!memcmp(&p &pp 8)) continue
,pp=p
,;out "mouse moved"
,
,int ttId=0; str ttText
,;----------- BEGIN EDIT --------------
,;Look where is mouse.
,;To show tooltip, set ttId (a unique nonzero number) and ttText.
,;Examples:
,
,int w=win(mouse)
,Acc a=acc(mouse)
,if wintest(w "Quick Macros" "QM_Editor") and acctest(a "tooltip1" "OUTLINEITEM" w "id=2202 SysTreeView32")
,,ttId=1
,,ttText="'tooltip1' in QM list of macros"
,else if wintest(w "Notepad" "Notepad") and acctest(a "Edit" "MENUITEM" w "Notepad" "" 0x1)
,,ttId=2
,,ttText="menu item 'Edit' in Notepad"
,;...
,
,;----------- END EDIT --------------
,
,int pttId
,if(ttId=pttId) continue
,if(pttId) shutdown -6 0 "ShowTooltip"
,pttId=ttId
,if(!ttId) continue
,;out ttText
,mac "ShowTooltip" "" ttText 30 p.x p.y ScreenWidth/2 1
,
Posts: 1,006
Threads: 330
Joined: Mar 2007
phenomenal!!!
Thanks so much
S
Posts: 1,058
Threads: 367
Joined: Oct 2007
Suppose you use flag TTS_CLOSE to use the "Close(x)" button to close the tooltip window. What is the optipum way to shutown the tooltip thread in this case?
This is what I use at present
Function ShowTooltip
rep
,0.1
,if(hid(hwndTT)); break
,
Posts: 12,075
Threads: 141
Joined: Dec 2002
I updated ShowTooltip code.
Posts: 1,058
Threads: 367
Joined: Oct 2007
Perfect, many thanks, regards.
Posts: 1,769
Threads: 410
Joined: Feb 2003
SWEET FANCY MOSES!! this is AWESOME!
Thanks to both of you!!!!
Posts: 26
Threads: 3
Joined: Apr 2011
How can i use this function to show a tooltip not from a coordinate, but from an tray icon? or, how to get the coordinates from the tray icon!
Posts: 12,075
Threads: 141
Joined: Dec 2002
Macro Macro1648
int w=win("" "Shell_TrayWnd")
Acc a.Find(w "PUSHBUTTON" "Quick Macros" "class=ToolbarWindow32" 0x1005)
int x y
a.Location(x y)
ShowTooltip "toltip" 3 x+10 y 0 1
For a.Find you need QM 2.3.3. With older QM versions use acc.
Posts: 26
Threads: 3
Joined: Apr 2011
Posts: 1,058
Threads: 367
Joined: Oct 2007
I almost expect the answer, neverthless I would dare the question : Is it possible to attach this tooltip to a window?
Regards, Simos
Posts: 12,075
Threads: 141
Joined: Dec 2002
Show automatically when mouse is over that window?
Is it your dialog , or any window of any application?
Posts: 1,058
Threads: 367
Joined: Oct 2007
Dear Gintaras,
Thanks for your response. It is a tolltip window produced with the ShowTooltip function above and I would like to have it moving attached to another window. I attach herewith your ShowTooltip function modified for this purpose, however, I do not like it, I am seeking something else more elegant.
Regards.
Function ShowTooltip_Attached
;\
function $text hwnd x y [maxTipWidth] [flags] [IconFile] ;;flags: 1 balloon (XP+) 2 Play Sound 4 First line in text is title 8 Show Close Button
;Written by SES 120821191645
;Shows tooltip that is attached to a control.
;Shows synchronously, ie waits timeS seconds. To show async, run in other thread (mac).
;text - text.
;timeS - time to show, s.
;x, y - position in screen relative to those of window hwnd
;maxTipWidth - max width. If nonzero, text can be multiline.
;IconFile : Intefer, Tooltip Icon, get it with ie. int IconFile=GetIcon(IconFile 0)
;For balloon :
;HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\EnableBalloonTips
;http://www.eggheadcafe.com/microsoft/VC-MFC/29399408/tooltip-not-showing-on-some-xp-computers.aspx
;http://support.microsoft.com/?id=307729
;C:\Documents and Settings\S.E.Simopoulos\My QM\Housekeeping\MicrosoftFixit50048.msi
;EXAMPLES
;ShowTooltip "test tooltip" 2 300 100
;mac "ShowTooltip" "" "test[]tooltip" 2 300 100 400 1
;With icon
;int IconFile=GetIcon("$user profile$\My Documents\Local Settings\sysman\Ico\djvu0409_dll_9.ico" 0)
;mac "ShowTooltip" "" "test[]tooltip" 4 300 100 400 1|2|4 IconFile
str stext=text ;; Added by SES on 111120193509
if(flags&4)
,str title.getl(text 0)
,stext.getl(text 1 2)
,
int st=TTS_NOPREFIX|TTS_ALWAYSTIP
if(flags&1) st|TTS_BALLOON
if(flags&2) bee "C:\WINDOWS\Media\Windows XP Balloon.wav"
;Show Close Button : It sould have also the following flags set : 1|4
if(flags&8) st|TTS_CLOSE
int hwndTT = CreateWindowEx(WS_EX_TOPMOST TOOLTIPS_CLASS 0 st 0 0 0 0 0 0 0 0)
TOOLINFOW ti.cbSize=44
ti.uFlags = TTF_TRACK
ti.lpszText=@stext
SendMessage(hwndTT, TTM_ADDTOOLW, 0, &ti)
;Add title and an icon to tooltip - Added by SES on 111120193509
if(flags&4)
,SendMessage(hwndTT TTM_SETTITLE IconFile title)
,DestroyIcon IconFile
if(maxTipWidth) SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, 0, maxTipWidth)
SendMessage(hwndTT, TTM_TRACKPOSITION, 0, MakeInt(x, y))
SendMessage(hwndTT, TTM_TRACKACTIVATE, 1, &ti)
opt waitmsg 1
int hx hy hxm hym
GetWinXY(hwnd hx hy)
mov hx+x hy+y hwndTT
hxm=hx
hym=hy
rep
,1
,if(flags&8)
,,if(hid(hwndTT)); break
,ifi- hwnd; break
,GetWinXY(hwnd hx hy)
,if hx=hxm and hy=hym; continue
,mov hx+x hy+y hwndTT
,hxm=hx
,hym=hy
,
DestroyWindow hwndTT
Posts: 12,075
Threads: 141
Joined: Dec 2002
Sorry, now cannot find time for this.
Posts: 1,058
Threads: 367
Joined: Oct 2007
Dear Gintaras,
I have no problem with it. It works. Many thanks for informing me. Regards. SImos.
Posts: 1,058
Threads: 367
Joined: Oct 2007
Is it possible to change the font of a tooltip and if yes, how?
I am aware of post Floating toolbar difficulties (toolbars in exe)
Posts: 12,075
Threads: 141
Joined: Dec 2002
Try TTM_SETTIPTEXTCOLOR:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
To disable visual styles:
SetWindowTheme hwnd L"" L""
|