Page 1 of 1

How do I make a hint in any coordinates?

Posted: Wed Mar 11, 2026 10:37 pm
by AZJIO
The preliminary version. But if I do not change the coordinates, the text is not updated.
Sometimes I process data and I need to output the current state. A hint near the mouse cursor or at the specified coordinates would be ideal.

Code: Select all

EnableExplicit

Global hIcon1, hIcon2, hIcon3
Global TTip
Global TipTime = 4
; Global TipStyle = 0
Global TipStyle = 64
Global TipWidth = 220
TipTime * 1000

Global p.POINT
Define i

#TTF_ABSOLUTE = $80
#TTF_TRACK = $20

Procedure BalloonTip()
	Protected null.w
	Protected TStyle = #TTS_NOPREFIX | #TTS_ALWAYSTIP | #WS_POPUP
	If TipStyle & #TTS_BALLOON
		TStyle | #TTS_BALLOON
	EndIf
	TTip = CreateWindowEx_(#WS_EX_TOPMOST, "tooltips_class32", 0, TStyle, 0, 0, 0, 0, 0, 0, GetModuleHandle_(0), 0)
	SetWindowTheme_(TTip, @null.w, @null.w)
; 	SendMessage_(TTip, #TTM_SETTIPTEXTCOLOR, GetSysColor_(#COLOR_INFOTEXT), 0)
; 	SendMessage_(TTip, #TTM_SETTIPBKCOLOR, GetSysColor_(#COLOR_INFOBK), 0)
	SendMessage_(TTip, #TTM_SETTIPTEXTCOLOR, $72ADC0, 0)
	SendMessage_(TTip, #TTM_SETTIPBKCOLOR, $222222, 0)
	SendMessage_(TTip, #TTM_SETMAXTIPWIDTH, 0, TipWidth)
	SendMessage_(TTip, #TTM_SETDELAYTIME, 2, TipTime)
EndProcedure

Procedure BalloonTip2(Tip$, Title$ = "", Icon = 0)
	If Asc(Title$)
		If Not TTip
			BalloonTip()
		EndIf
		SendMessage_(TTip, #TTM_SETTITLE, Icon, @Title$)
	EndIf

	Protected ti.TOOLINFO
	ti\cbSize = SizeOf(ti)
	ti\hInst = GetModuleHandle_(0)
; 	ti\uFlags = #TTF_SUBCLASS
	ti\uFlags = #TTF_SUBCLASS | #TTF_ABSOLUTE | #TTF_TRACK | #TTM_TRACKPOSITION
; 	ti\hwnd = GetDesktopWindow_()
	ti\hwnd = 0
	ti\uId = 0
	ti\rect\left = 1200 ; x (without #TTF_ABSOLUTE | #TTF_TRACK)
	ti\rect\top = 0
	ti\rect\bottom = 1110 ; y
	ti\rect\right = 1200 ; x
	ti\lpszText = @Tip$
	SendMessage_(TTip, #TTM_ADDTOOL, 0, ti)
	SendMessage_(TTip, #TTM_TRACKACTIVATE, 1, @ti)
	SendMessage_(TTip, #TTM_TRACKPOSITION, 0, p\x | (p\y << 16))
; 	SendMessage_(TTip, #TTM_TRACKPOSITION, 0, @p)
EndProcedure

If Not TipStyle & 1
	BalloonTip()
EndIf


; SmallIcon
; ExtractIconEx_("Shell32.dll", 3, 0, @hIcon1, 1)

; LargeIcon
ExtractIconEx_("Shell32.dll", 22, @hIcon1, 0, 1)

p\x = 200 ; #TTF_ABSOLUTE | #TTF_TRACK
p\y = 200
For i = 1 To 5
	p\x + 5
	BalloonTip2("The popup hint is placed anywhere by coordinates", "title " + Str(i), hIcon1)
	Delay(700)
Next

p\x = 230 ; #TTF_ABSOLUTE | #TTF_TRACK
p\y = 200
For i = 6 To 10
	BalloonTip2("The popup hint is placed anywhere by coordinates" + Str(i), "title " + Str(i), hIcon1)
; 	RedrawWindow_(TTip, 0, 0, #RDW_ERASE | #RDW_INVALIDATE | #RDW_ERASENOW)
	Delay(700)
Next
Delay(1500)

DestroyIcon_(hIcon1)
DestroyWindow_(TTip)

Re: How do I make a hint in any coordinates?

Posted: Thu Mar 12, 2026 3:06 pm
by ebs
Added 'ChangeTitleText()' procedure to change balloon tooltip title and/or text:

Code: Select all

EnableExplicit

Global hIcon1, hIcon2, hIcon3
Global TTip
Global TipTime = 4
; Global TipStyle = 0
Global TipStyle = 64
Global TipWidth = 220
TipTime * 1000

Global p.POINT
Define i

#TTF_ABSOLUTE = $80
#TTF_TRACK = $20

Procedure BalloonTip()
	Protected null.w
	Protected TStyle = #TTS_NOPREFIX | #TTS_ALWAYSTIP | #WS_POPUP
	If TipStyle & #TTS_BALLOON
		TStyle | #TTS_BALLOON
  EndIf
	TTip = CreateWindowEx_(#WS_EX_TOPMOST, "tooltips_class32", 0, TStyle, 0, 0, 0, 0, 0, 0, GetModuleHandle_(0), 0)
	SetWindowTheme_(TTip, @null.w, @null.w)
  ; 	SendMessage_(TTip, #TTM_SETTIPTEXTCOLOR, GetSysColor_(#COLOR_INFOTEXT), 0)
  ; 	SendMessage_(TTip, #TTM_SETTIPBKCOLOR, GetSysColor_(#COLOR_INFOBK), 0)
	SendMessage_(TTip, #TTM_SETTIPTEXTCOLOR, $72ADC0, 0)
	SendMessage_(TTip, #TTM_SETTIPBKCOLOR, $222222, 0)
	SendMessage_(TTip, #TTM_SETMAXTIPWIDTH, 0, TipWidth)
	SendMessage_(TTip, #TTM_SETDELAYTIME, 2, TipTime)
EndProcedure

Procedure BalloonTip2(Tip$, Title$ = "", Icon = 0)
	If Asc(Title$)
		If Not TTip
			BalloonTip()
    EndIf
		SendMessage_(TTip, #TTM_SETTITLE, Icon, @Title$)
  EndIf
  
	Protected ti.TOOLINFO
	ti\cbSize = SizeOf(ti)
	ti\hInst = GetModuleHandle_(0)
  ; 	ti\uFlags = #TTF_SUBCLASS
	ti\uFlags = #TTF_SUBCLASS | #TTF_ABSOLUTE | #TTF_TRACK | #TTM_TRACKPOSITION
  ; 	ti\hwnd = GetDesktopWindow_()
	ti\hwnd = 0
	ti\uId = 0
	ti\rect\left = 1200 ; x (without #TTF_ABSOLUTE | #TTF_TRACK)
	ti\rect\top = 0
	ti\rect\bottom = 1110 ; y
	ti\rect\right = 1200 ; x
	ti\lpszText = @Tip$
	SendMessage_(TTip, #TTM_ADDTOOL, 0, ti)
	SendMessage_(TTip, #TTM_TRACKACTIVATE, 1, @ti)
	SendMessage_(TTip, #TTM_TRACKPOSITION, 0, p\x | (p\y << 16))
  ; 	SendMessage_(TTip, #TTM_TRACKPOSITION, 0, @p)
EndProcedure

If Not TipStyle & 1
	BalloonTip()
EndIf

;- new procedure to change balloon tip title and/or text
Procedure ChangeTitleText(Title.s = "", Text.s = "")
  Protected ti.TOOLINFO
   
  If Title
    SendMessage_(TTip, #TTM_SETTITLE, hIcon1, @Title)
  EndIf

  If Text
    ti\cbSize   = SizeOf(TOOLINFO)
    ti\uFlags   = #TTF_IDISHWND | #TTF_SUBCLASS
    ti\hwnd     = 0
    ti\uId      = 0
    ti\lpszText = @Text
    SendMessage_(TTip, #TTM_UPDATETIPTEXT, 0, @ti)
  EndIf
EndProcedure

; SmallIcon
; ExtractIconEx_("Shell32.dll", 3, 0, @hIcon1, 1)

; LargeIcon
ExtractIconEx_("Shell32.dll", 22, @hIcon1, 0, 1)

p\x = 200 ; #TTF_ABSOLUTE | #TTF_TRACK
p\y = 200
For i = 1 To 5
	p\x + 5
	BalloonTip2("The popup hint is placed anywhere by coordinates", "title " + Str(i), hIcon1)
	Delay(700)
Next

; p\x = 230 ; #TTF_ABSOLUTE | #TTF_TRACK
; p\y = 200
For i = 6 To 10
  ;- change tip title and text
  ChangeTitleText("Title " + Str(i), "This is step " + Str(i)) 
	;;;BalloonTip2("The popup hint is placed anywhere by coordinates" + Str(i), "title " + Str(i), hIcon1)
  ; 	RedrawWindow_(TTip, 0, 0, #RDW_ERASE | #RDW_INVALIDATE | #RDW_ERASENOW)
	Delay(700)
Next
Delay(1500)

DestroyIcon_(hIcon1)
DestroyWindow_(TTip)

Re: How do I make a hint in any coordinates?

Posted: Thu Mar 12, 2026 3:49 pm
by Piero
Dear AZJIO, I'm subcoscious in this moment (did a lot of stuff past night; I'm very tired…) but hope the Wise Admins will let me communicate to you a Glorious, never-heard-before, Heavenly Message: please get a Mac