StatusBar & #SB_SETTIPTEXT

Just starting out? Need help? Post your questions and find answers here.
User_Russian
Addict
Addict
Posts: 1518
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

StatusBar & #SB_SETTIPTEXT

Post by User_Russian »

Why is not the tool tip?

Code: Select all

#SBT_TOOLTIPS = $800
#SB_SETICON = #WM_USER + 15
LoadImage(0,#PB_Compiler_Home+"Examples\Sources\Data\CdPlayer.ico")

If OpenWindow(0, 0, 0, 400, 100, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  hSB=CreateStatusBar(0, WindowID(0))
  SetWindowLongPtr_(hSB, #GWL_STYLE,GetWindowLongPtr_(hSB, #GWL_STYLE)|#SBT_TOOLTIPS)
  AddStatusBarField(40)
  AddStatusBarField(40)
  StatusBarImage(0, 1, ImageID(0))
  SendMessage_(hSB, #SB_SETTIPTEXT, 1, @"ToolTip")
  
  Repeat
    Event = WaitWindowEvent()
    
  Until Event = #PB_Event_CloseWindow
EndIf
If StatusBar created using WinAPI, then there is a hint.

Code: Select all

#SBT_TOOLTIPS = $800
#SB_SETICON = #WM_USER + 15
LoadImage(0,#PB_Compiler_Home+"Examples\Sources\Data\CdPlayer.ico")

If OpenWindow(0, 0, 0, 400, 100, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  hSB=CreateWindowEx_(0,"msctls_statusbar32","",#WS_VISIBLE|#WS_CHILD|#SBT_TOOLTIPS, 0, 300, 100, 24, WindowID(0),0,0,0)
  z.q=$008000000040
  SendMessage_(hSB, #SB_SETPARTS, 2, @z)
  SendMessage_(hSB, #SB_SETICON, 1, ImageID(0))
  SendMessage_(hSB, #SB_SETTIPTEXT, 1, "ToolTip")
  
  Repeat
    Event = WaitWindowEvent()
    
  Until Event = #PB_Event_CloseWindow
EndIf
What should I do to work with the tool tip CreateStatusBar()?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: StatusBar & #SB_SETTIPTEXT

Post by IdeasVacuum »

I could be wrong but I think the PB Status bar might be 'home grown', perhaps for cross-platform purposes. If so, that would explain why the tooltips fail. If your app is Windows only, then you have already found your solution. I can't think of a reasonable work-around, though I wouldn't mind betting that netmaestro would have a good idea. Perhaps placing a transparent gadget over the top of the StatusBar - sounds really clumsy, but then only you would know it was there..... The other possibility would be a balloon type tip, either API or DIY (2D sprite), and track the mouse cursor position.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: StatusBar & #SB_SETTIPTEXT

Post by skywalk »

From ts-soft...use a container + textgadget + resize for a statusbar.

Code: Select all

OpenWindow(0, #PB_Ignore, #PB_Ignore, 640, 480, "Statusbar Dummy", #PB_Window_SizeGadget | #PB_Window_SystemMenu)
ContainerGadget(0, 0, 0, 0, 0, #PB_Container_Single)
LoadFont(0, "Consolas", 12)
StringGadget(1, 1, 1, 180, 24, "Status", #PB_String_BorderLess | #PB_Text_Center)
SetGadgetFont(1, FontID(0))
SetGadgetColor(1,#PB_Gadget_BackColor,RGB(219, 175, 175))
GadgetToolTip(0, "I'm a Statusbar!")
GadgetToolTip(1, "I'm a Statusbar Entry!")
CloseGadgetList()
ResizeGadget(0, 0, WindowHeight(0) - 24, WindowWidth(0), 24)
Repeat
  Select WaitWindowEvent()
  Case #PB_Event_CloseWindow
    Break
  Case #PB_Event_SizeWindow
    ResizeGadget(0, 0, WindowHeight(0) - 24, WindowWidth(0), 24)
  EndSelect
ForEver
Last edited by skywalk on Wed Dec 26, 2018 6:11 pm, edited 1 time in total.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: StatusBar & #SB_SETTIPTEXT

Post by netmaestro »

It's a normal windows statusbar control alright, there's nothing special being done with it by PB. The code as presented is written correctly but there is one factor keeping it from working: Some control styles cannot be added in after creation and this is one of them. Best thing to do here imho is put in a feature request for statusbar tooltips.
BERESHEIT
User_Russian
Addict
Addict
Posts: 1518
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: StatusBar & #SB_SETTIPTEXT

Post by User_Russian »

Used to display icons ImageGadget in the status bar.

Code: Select all

LoadImage(0,#PB_Compiler_Home+"Examples\Sources\Data\CdPlayer.ico")

If OpenWindow(0, 0, 0, 400, 100, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  hSB=CreateStatusBar(0, WindowID(0))
  AddStatusBarField(40)
  AddStatusBarField(40)
  
  hList=UseGadgetList(hSB)
  ImageGadget(0, 44, 2, 16, 16,ImageID(0))
  GadgetToolTip(0,"ToolTip")
  UseGadgetList(hList)
  
  Repeat
    Event = WaitWindowEvent()
    
  Until Event = #PB_Event_CloseWindow
EndIf
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: StatusBar & #SB_SETTIPTEXT

Post by RASHAD »

Code: Select all

Global  Tip
LoadImage(0,#PB_Compiler_Home+"Examples\Sources\Data\CdPlayer.ico")
If OpenWindow(0, 0, 0, 400, 300, "StatusBar ToolTip", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget| #PB_Window_SizeGadget|#PB_Window_ScreenCentered)
  hSB=CreateStatusBar(0, WindowID(0))
  SendMessage_(hSB, #SB_SETMINHEIGHT, 30, 0)
  SendMessage_(hSB, #WM_SIZE, 0,0)
  AddStatusBarField(40)
  AddStatusBarField(40)
  StatusBarImage(0, 0, ImageID(0))
  StatusBarImage(0, 1, ImageID(0))  
  Tip = CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX ,0,0,0,0,0,0,GetModuleHandle_(0),0)
  SendMessage_(Tip, #TTM_SETDELAYTIME, #TTDT_INITIAL, 10)
  SendMessage_(Tip, #TTM_SETDELAYTIME, #TTDT_AUTOPOP, 1000)  
   ti.TOOLINFO 
   ti\cbSize   = SizeOf(TOOLINFO);
   ti\uFlags   = #TTF_IDISHWND | #TTF_SUBCLASS
   ti\uId=hSB

Repeat
Select WaitWindowEvent()
   Case #PB_Event_CloseWindow
       Quit = 1
        
   Case #WM_MOUSEMOVE
        x = WindowMouseX(0)
       If x > 0 And x < 40
           ti\lpszText = @"Tool #1"
           SendMessage_(Tip, #TTM_ADDTOOL, 0, ti)
        ElseIf x > 40 And x < 80
           ti\lpszText = @"Tool #2"
           SendMessage_(Tip, #TTM_ADDTOOL, 0, ti)
        ElseIf x > 80
           ti\lpszText = @"Tool #3"
           SendMessage_(Tip, #TTM_ADDTOOL, 0, ti)
        EndIf

    EndSelect
Until Quit = 1
EndIf

Edit: Modified
Egypt my love
Post Reply