I've checked GadgetToolTip(#Gadget, Text$) and I noticed that Menu is not part of the gadget supported.
Is there a simple way to add tool tips to a menu item?
Thanks.
MenuItem tool tips
Re: MenuItem tool tips
Hi
For Windows
For Windows
Code: Select all
Global tip,ti.TOOLINFO
Procedure CurPos(parameter)
Repeat
GetMenuItemRect_(WindowID(0),MenuID(0),0,r.RECT)
GetMenuItemRect_(WindowID(0),MenuID(0),1,r2.RECT)
GetMenuItemRect_(WindowID(0),MenuID(0),2,r3.RECT)
GetCursorPos_(p.POINT)
If PtInRect_(r, PeekQ(@p))
ti\lpszText=@" One"
SendMessage_(tip, #TTM_ADDTOOL, 0, ti)
ElseIf PtInRect_(r2, PeekQ(@p))
ti\lpszText=@" Two"
SendMessage_(tip, #TTM_ADDTOOL, 0, ti)
ElseIf PtInRect_(r3, PeekQ(@p))
ti\lpszText=@" Three"
SendMessage_(tip, #TTM_ADDTOOL, 0, ti)
Else
SendMessage_(tip, #TTM_DELTOOL, 0, ti)
EndIf
ForEver
EndProcedure
If OpenWindow(0, 100, 150, 195, 260, "PureBasic - Menu")
If CreateMenu(0, WindowID(0))
MenuTitle("File")
MenuItem( 1, "&Load...")
MenuItem( 2, "Save")
MenuItem( 3, "Save As...")
MenuBar()
OpenSubMenu("Recents")
MenuItem( 5, "Pure.png")
MenuItem( 6, "Basic.jpg")
OpenSubMenu("Even more !")
MenuItem( 12, "Yeah")
CloseSubMenu()
MenuItem( 13, "Rocks.tga")
CloseSubMenu()
MenuBar()
MenuItem( 7, "&Quit")
MenuTitle("Edition")
MenuItem( 8, "Cut")
MenuItem( 9, "Copy")
MenuItem(10, "Paste")
MenuTitle("?")
MenuItem(11, "About")
EndIf
DisableMenuItem(0, 3, 1)
DisableMenuItem(0, 13, 1)
Tip = CreateWindowEx_(#WS_EX_TOPMOST,"Tooltips_Class32",0, #TTS_ALWAYSTIP|#TTS_BALLOON,#CW_USEDEFAULT, #CW_USEDEFAULT,#CW_USEDEFAULT,#CW_USEDEFAULT, WindowID(0),0,GetModuleHandle_(0),0)
SetWindowTheme_(Tip, @null.w, @null.w)
SendMessage_(tip,#TTM_SETTIPTEXTCOLOR,$0202FD,0)
SendMessage_(tip,#TTM_SETTIPBKCOLOR,$DCFFFF,0)
SendMessage_(Tip, #TTM_SETDELAYTIME, #TTDT_INITIAL,100)
SendMessage_(Tip, #TTM_SETDELAYTIME, #TTDT_AUTOPOP,1000)
ti\cbSize = SizeOf(ti)
ti\uFlags = #TTF_IDISHWND|#TTF_SUBCLASS
ti\uId = WindowID(0)
thread = CreateThread(@CurPos(),30)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Menu
Select EventMenu() ; To see which menu has been selected
Case 11 ; About
MessageRequester("About", "Cool Menu example", 0)
Default
MessageRequester("Info", "MenuItem: "+Str(EventMenu()), 0)
EndSelect
Case #PB_Event_CloseWindow
KillThread(thread)
Quit = 1
EndSelect
Until Quit = 1
EndIf
End
Egypt my love
Re: MenuItem tool tips
Much simple and should be cross platform
Edit :Bugs fixed

Code: Select all
Global x0,x1,x2,x3,y0,y1,Text1$,Text2$,Text3$
ExamineDesktops()
Procedure CurPos(parameter)
Repeat
x = DesktopMouseX()
y = DesktopMouseY()
x0 = WindowX(0,#PB_Window_FrameCoordinate)+4
y0 = WindowY(0,#PB_Window_InnerCoordinate) - MenuHeight()
y1 = y0 + MenuHeight()
If x >= x0 And x <= (x0+x1) And y >= y0 And y <= y1
ResizeGadget(1,0,5,#PB_Ignore,#PB_Ignore)
SetGadgetText(1,Text1$)
Delay(100)
ElseIf x >= (x0+x1) And x <= (x0+x1+x2) And y >= y0 And y <= y1
ResizeGadget(1,x11,5,#PB_Ignore,#PB_Ignore)
SetGadgetText(1,Text2$)
Delay(100)
ElseIf x >= (x0+x1+x2) And x <= (x0+x1+x2+x3) And y >= y0 And y <= y1
ResizeGadget(1,x22,5,#PB_Ignore,#PB_Ignore)
SetGadgetText(1,Text3$)
Delay(100)
Else
ResizeGadget(1,-100,0,#PB_Ignore,#PB_Ignore)
SetGadgetText(1,"")
Delay(100)
EndIf
ForEver
EndProcedure
If OpenWindow(0, 100, 150, 195, 260, "PureBasic - Menu")
TextGadget(1,10,60,100,16,"tiuiutiti",#PB_Text_Center)
SetGadgetColor(1,#PB_Gadget_BackColor,$DBFEFD)
SetGadgetColor(1,#PB_Gadget_FrontColor,$0000FF)
If CreateMenu(0, WindowID(0))
MenuTitle("File")
MenuItem( 1, "&Load...")
MenuItem( 2, "Save")
MenuItem( 3, "Save As...")
MenuBar()
OpenSubMenu("Recents")
MenuItem( 5, "Pure.png")
MenuItem( 6, "Basic.jpg")
OpenSubMenu("Even more !")
MenuItem( 12, "Yeah")
CloseSubMenu()
MenuItem( 13, "Rocks.tga")
CloseSubMenu()
MenuBar()
MenuItem( 7, "&Quit")
MenuTitle("Edition")
MenuItem( 8, "Cut")
MenuItem( 9, "Copy")
MenuItem(10, "Paste")
MenuTitle("?")
MenuItem(11, "About")
EndIf
DisableMenuItem(0, 3, 1)
DisableMenuItem(0, 13, 1)
sp$ = Space(4)
StartDrawing(WindowOutput(0))
x1 = TextWidth(sp$+GetMenuTitleText(0,0));*5
x2 = TextWidth(sp$+GetMenuTitleText(0,1));*5
x3 = TextWidth(sp$+GetMenuTitleText(0,2));*5
StopDrawing()
Text1$ = "File ToolTip"
Text2$ = "Edition ToolTip"
Text3$ = "Help ToolTip"
thread = CreateThread(@CurPos(),30)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Menu
Select EventMenu() ; To see which menu has been selected
Case 11 ; About
MessageRequester("About", "Cool Menu example", 0)
Default
MessageRequester("Info", "MenuItem: "+Str(EventMenu()), 0)
EndSelect
Case #PB_Event_CloseWindow
KillThread(thread)
Quit = 1
EndSelect
Until Quit = 1
EndIf
End
Last edited by RASHAD on Wed Apr 29, 2015 7:41 pm, edited 1 time in total.
Egypt my love
- Mindphazer
- Enthusiast
- Posts: 464
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: MenuItem tool tips
Hi Rashad
It doesn't work on OS X because on OS X menus are -always- on the top of the screen, they are not attached to a window...
It doesn't work on OS X because on OS X menus are -always- on the top of the screen, they are not attached to a window...
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...
Re: MenuItem tool tips
Thanks.
Too complicated for what I planned currently. I was thinking just a few lines, the way GadgetTooltip works.
Anyway, thanks again. I'll keep this in mind when my app is ready to use it.
Too complicated for what I planned currently. I was thinking just a few lines, the way GadgetTooltip works.
Anyway, thanks again. I'll keep this in mind when my app is ready to use it.