
Change tooltip for 'minimize' button?
Change tooltip for 'minimize' button?
Is it possible to change the tooltip for the standard 'minimize' button?


Re: Change tooltip for 'minimize' button?
Hi
Edit :Code modified
Edit :Modified again
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
Edit :Modified again
Last edited by RASHAD on Fri Nov 16, 2012 12:08 pm, edited 3 times in total.
Egypt my love
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Change tooltip for 'minimize' button?
Rashad, I see no difference with your code on XP? Same tooltip text as normal.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Change tooltip for 'minimize' button?
Nope? I put the mouse over all 3 buttons, and no tooltip appears for about 5 seconds or so, and then I just see "Minimize", "Maximize" or "Close" like normal. What's meant to happen?
[Edit] Okay, it shows the longer tooltip message for minimize if I move the mouse onto the box from the left or right, but not if I move it on from up or down. Any way to fix that?
[Edit] Okay, it shows the longer tooltip message for minimize if I move the mouse onto the box from the left or right, but not if I move it on from up or down. Any way to fix that?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Change tooltip for 'minimize' button?
Hi RASHAD. Nice code, although the problem for MachineCode may be the WinXP themes. I see that you've disabled it in your modified code, but IIRC, that doesn't always work.
BTW, in the callback, what's the relevance of hiding windows 65550 To 65600?
BTW, in the callback, what's the relevance of hiding windows 65550 To 65600?
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Change tooltip for 'minimize' button?
Rashad, that works every time now, yes.
But not with a balloon shape, it's just a rectangle. Best compromise, I guess?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Change tooltip for 'minimize' button?
Hello again, RASHAD. I noticed that you had actually disabled the tooltip for the Minimize button (65550 To 65600?) and activated a custom-drawn tooltip for its region of the window. Great workaround, although I'm still wondering why the callback hides 50 windows.
Regarding the issue MachineCode had with the windows themes/styles, you seem to have circumvented it with the SetWindowTheme() function. However, in one of my earlier codes, the custom-drawn tooltip stops showing after an initial time-out. I was hoping you might know the reason behind this: 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?
Regarding the issue MachineCode had with the windows themes/styles, you seem to have circumvented it with the SetWindowTheme() function. However, in one of my earlier codes, the custom-drawn tooltip stops showing after an initial time-out. I was hoping you might know the reason behind this:
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
EndTexas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: Change tooltip for 'minimize' button?
On 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?
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.
"Have you tried turning it off and on again ?"
Re: Change tooltip for 'minimize' button?
Thanks Rashad!
Re: Change tooltip for 'minimize' button?
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.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: Change tooltip for 'minimize' button?
@ti-994a
I remember doing something like destroying and recreating the tooltip, or disabling it in some way and re-enabling him when the mouse pointer was leaving the icon area, I don't remember the details... anyway a quick search brought this thread out
http://stackoverflow.com/questions/5597 ... -first-use
I remember doing something like destroying and recreating the tooltip, or disabling it in some way and re-enabling him when the mouse pointer was leaving the icon area, I don't remember the details... anyway a quick search brought this thread out
http://stackoverflow.com/questions/5597 ... -first-use
"Have you tried turning it off and on again ?"
Re: Change tooltip for 'minimize' button?
@jassing you are welcome
@TI-994A
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
Next code to solve windows XP bug
Hope you like it
@TI-994A
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
Next code to solve windows XP bug
Hope you like it
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
Egypt my love
Re: Change tooltip for 'minimize' button?
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
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
