Change tooltip for 'minimize' button?
Posted: Fri Nov 16, 2012 10:43 am
Is it possible to change the tooltip for the standard 'minimize' button?


http://www.purebasic.com
https://www.purebasic.fr/english/

Code: Select all
Global hToolTip,hwnd
Procedure WinCallback(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NCMOUSEMOVE
If wParam = #HTMINBUTTON
For i = 65550 To 65600
If IsWindowVisible_(i)
ShowWindow_(i, #SW_HIDE)
EndIf
Next
EndIf
EndSelect
ProcedureReturn result
EndProcedure
Procedure.l AddTooltips()
hToolTip = CreateWindowEx_(0, "ToolTips_Class32", "", #WS_POPUP |#TTS_NOPREFIX |#TTS_ALWAYSTIP, 0, 0, 0, 0, WindowID(0), 0, GetModuleHandle_(0), 0)
SetWindowPos_(hToolTip, #HWND_TOPMOST , 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
SendMessage_(hToolTip, #TTM_SETDELAYTIME, #TTDT_INITIAL,10)
SetWindowTheme_(hToolTip, @null.w, @null.w)
ttAdd.TOOLINFO\cbSize = SizeOf(TOOLINFO)
ttAdd\uFlags = #TTF_SUBCLASS
ttAdd\hwnd = WindowID(0)
ttAdd\hInst = 0
buttonW = GetSystemMetrics_(#SM_CXSIZE)
buttonH = GetSystemMetrics_(#SM_CYSIZE)
winW = WindowWidth(0)
ttAdd\uId = #HTMINBUTTON
SetRect_(@ttAdd\rect,winW - 3*buttonW, - buttonH - 3, winW - 2*buttonW,- 3)
ttAdd\lpszText = @"Press to minimize to system tray"
SendMessage_(hToolTip, #TTM_ADDTOOL, 0, ttAdd)
SendMessage_(hToolTip, #TTM_UPDATE , 0, 0)
ProcedureReturn hToolTip
EndProcedure
hwnd = OpenWindow(0, 0, 0, 300, 300, "Custom Caption Tooltips", #PB_Window_SizeGadget | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget| #PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
SetWindowCallback(@WinCallback())
AddTooltips()
SetActiveWindow(0)
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
End
Code: Select all
EnableExplicit
Enumeration
#MainWindow
#TextInput
#ToolTipIcon
EndEnumeration
Define.i toolTip, wFlags, tti.TOOLINFO
Define.s iconFileName, defaultPathFile, displayPattern
defaultPathFile = "C:\"
displayPattern = "Icon Files (*.ico) | *.ico"
iconFileName = OpenFileRequester("Please choose an icon to use", defaultPathFile, displayPattern, 0)
If iconFileName And LoadImage(#ToolTipIcon, iconFileName)
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 300, 300, "Graphic Tooltips", wFlags)
StringGadget(#TextInput, 50, 100, 200, 30, "Hover mouse to see the graphic tooltip...")
toolTip = CreateWindowEx_(0, #TOOLTIPS_CLASS, #NULL$, #TTS_BALLOON, 0, 0, 0, 0, GadgetID(#TextInput), 0, GetModuleHandle_(0), 0)
With tti
\cbSize = SizeOf(TOOLINFO)
\hWnd = WindowID(#MainWindow)
\uId = GadgetID(#TextInput)
\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS
\lpszText = @"A gadget tooltip with graphics..."
EndWith
SendMessage_(toolTip, #TTM_ADDTOOL, 0, tti)
SendMessage_(toolTip, #TTM_SETMAXTIPWIDTH, 0, 200)
SendMessage_(toolTip, #TTM_SETTITLE, ImageID(#ToolTipIcon), "Custom Tooltip")
While WaitWindowEvent() ! #PB_Event_CloseWindow : CloseWindow : Wend
EndIf
EndOn windows XP only ? Because that's an XP bug if I'm not mistaken.TI-994A wrote: If the mouse pointer is left on the gadget and the tooltip is allowed to fade-out on its own, it's gone for good. Any idea what may be causing this?
Hi luis. You're right, once they time out, they don't come back until another is popped first. Strange behaviour. Thanks for pointing that out.luis wrote:Try do do the same with some other program iconized in the notification area. The tooltip doesn't come back. If you go to another icon with a tooltip, the new tooltip will re-enable the one precedently disabled.
Code: Select all
EnableExplicit
Enumeration
#MainWindow
#TextInput
#ToolTipIcon
EndEnumeration
Define.i wFlags, tti.TOOLINFO
Define.s iconFileName, defaultPathFile, displayPattern
Global Result,m.MSG,tooltip
Procedure WndProc(hwnd, uMsg, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
If uMsg = #WM_MOUSEMOVE
m.MSG
m\hwnd = hwnd
m\message = uMsg
m\wParam = wParam
m\lParam = lParam
SendMessage_(tooltip, #TTM_RELAYEVENT, 0,m)
EndIf
ProcedureReturn Result
EndProcedure
defaultPathFile = "C:\"
displayPattern = "Icon Files (*.ico) | *.ico"
iconFileName = OpenFileRequester("Please choose an icon to use", defaultPathFile, displayPattern, 0)
If iconFileName And LoadImage(#ToolTipIcon, iconFileName)
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 300, 300, "Graphic Tooltips", wFlags)
StringGadget(#TextInput, 50, 100, 200, 30, "Hover mouse to see the graphic tooltip...")
toolTip = CreateWindowEx_(0, "Tooltips_Class32", "", #TTS_ALWAYSTIP|#TTS_BALLOON, 0, 0, 0, 0, GadgetID(#TextInput), 0, GetModuleHandle_(0), 0)
tti\cbSize = SizeOf(TOOLINFO)
tti\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS
tti\hWnd = GadgetID(#TextInput)
tti\uId = GadgetID(#TextInput)
tti\lpszText = @"A gadget tooltip with graphics..."
SendMessage_(toolTip, #TTM_ADDTOOL, 0, tti)
SendMessage_(toolTip, #TTM_SETMAXTIPWIDTH, 0, 200)
SendMessage_(toolTip, #TTM_SETTITLE, ImageID(#ToolTipIcon), "Custom Tooltip")
SetWindowCallback(@WndProc())
While WaitWindowEvent() ! #PB_Event_CloseWindow : CloseWindow : Wend
EndIf
End
Wow! Where do you get these details?RASHAD wrote:For 65550 To 65600 question that is because the handle of the tip is different for each windows version but usually it is between that range
Hi RASHAD. Shoukran. I was struggling with that for some time, but never knew about the #TTM_RELAYEVENT message. It works great now. Thank you.RASHAD wrote:Next code to solve windows XP bug