December 01, 2020, 02:07:50 PM

Author Topic: [bb] Advance Status bar by Red [ 1+ years ago ]  (Read 1153 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Advance Status bar by Red [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : Advance Status bar
Author : Red
Posted : 1+ years ago

Description : Userlibs : /userlibs/user32.decls
Code: [Select]
SendMessageSTRING%(hwnd%, msg%, wParam%, mParam$):"SendMessageA"
SendMessageBANK%(hwnd%, msg%, wParam%, mParam*):"SendMessageA"
SendMessage%(hwnd%, msg%, wParam%, mParam%):"SendMessageA"

FindWindowEx%(hParent,hChild,classname$,title$):"FindWindowExA"
GetActiveWindow%():"GetActiveWindow"


How to use  :
Code: [Select]
STATUSBAR=SetCurrentWindowStatus(2)
SetStatusFieldWidth STATUSBAR,0,60 ;width = 60 px
SetStatusFieldWidth STATUSBAR,1    ;width = infinite

SetStatusFieldText STATUSBAR,0,curY+":"+curX,2,2
SetStatusFieldText STATUSBAR,1,bienvenue$,0,1


Blitz functions : [/i]

Code :
Code: BlitzBasic
  1. ; ===============================================================
  2. ; Set field count of statusbar and retrieve the status handle
  3. ; ===============================================================
  4.  
  5. Function SetCurrentWindowStatus%(count)
  6.         Local SB_SIMPLE=$409
  7.         Local SB_SETPARTS=$404
  8.         Local SB_ISSIMPLE=$400+14
  9.        
  10.         If count>256 Then RuntimeError("Status : no more 256 fields !")
  11.  
  12.         ;handle of status      
  13.         Local sb=FindWindowEx(GetActiveWindow(),0,"msctls_statusbar32","")
  14.        
  15.         ;disable simple-text mode
  16.         SendMessage(sb,SB_SIMPLE,0,0)
  17.                        
  18.         ;create Fields
  19.         Local fields=CreateBank(256*4)
  20.         For i=1 To count
  21.                 PokeInt fields,4*(i-1),-1
  22.         Next   
  23.         SendMessageBANK(sb,SB_SETPARTS,count,fields)   
  24.         FreeBank fields
  25.        
  26.         Return sb
  27. End Function
  28.  
  29. ; ================================
  30. ; Set width of one field
  31. ; ================================
  32.  
  33. ;Note : width,style,tooltip are some optional parameters
  34.  
  35. Function SetStatusFieldWidth (sb,index,width=-1)
  36.         Local SB_SETPARTS=$404
  37.         Local SB_GETPARTS=$406
  38.        
  39.         ;set width
  40.         Local fields=CreateBank(256*4)
  41.         Local count=SendMessageBANK(sb,SB_GETPARTS,256,fields)
  42.        
  43.         If index>count-1 Then RuntimeError("The index is out of range")
  44.        
  45.         Local border=0
  46.         If width<>-1
  47.                 If index=0
  48.                         border=0       
  49.                 Else
  50.                         border=PeekInt(fields,(index-1)*4)
  51.                 EndIf
  52.         EndIf
  53.         PokeInt fields,index*4,border+width
  54.         SendMessageBANK(sb,SB_SETPARTS,count,fields)   
  55.         FreeBank fields
  56.                
  57. End Function
  58.  
  59. ; ================================
  60. ; Change text of one field
  61. ; ================================
  62.  
  63. ;Note : style and align are optional parameters
  64. ;Note : style=0 (flat) =1 (low border) =2 (high border)
  65. ;Note : align=0 left   =1 (right)      =2 (center)
  66.  
  67. Function SetStatusFieldText(sb,index,txt$,align=0,style=1)
  68.         Local SB_SETTEXT=$401
  69.     Local SBT_NOBORDERS=$100
  70.         Local SBT_POPOUT=$200
  71.        
  72.         ;set text
  73.         Local fstyle
  74.         Select style
  75.                 Case 0
  76.                         fstyle = SBT_NOBORDERS
  77.                 Case 1
  78.                         fstyle = 0  
  79.                 Case 2
  80.                         fstyle = SBT_POPOUT
  81.         End Select             
  82.         Select align
  83.                 Case 1
  84.                         txt$ = Chr(9)+txt$  
  85.                 Case 2
  86.                         txt$ = Chr(9)+txt$+Chr(9)
  87.         End Select     
  88.         SendMessageSTRING(sb,SB_SETTEXT,index Or fstyle,txt$)
  89. End Function


Comments :


TAS(Posted 1+ years ago)

 I could use an example or a screenshot of what this does.  I tend to use the status bar a lot.  This code appears to break the bar into sections which could be very useful.


KnorxThieus(Posted 1+ years ago)

 Thank you very much, you are my hero!!! :-)


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal