Code archives/BlitzPlus Gui/Advance Status bar

This code has been declared by its author to be Public Domain code.

Download source code

Advance Status bar by Red2003
Userlibs : /userlibs/user32.decls
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 :
	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 :
; ===============================================================
; Set field count of statusbar and retrieve the status handle
; ===============================================================

Function SetCurrentWindowStatus%(count)
	Local SB_SIMPLE=$409
	Local SB_SETPARTS=$404
	Local SB_ISSIMPLE=$400+14
	
	If count>256 Then RuntimeError("Status : no more 256 fields !")

	;handle of status	
	Local sb=FindWindowEx(GetActiveWindow(),0,"msctls_statusbar32","")
	
	;disable simple-text mode
	SendMessage(sb,SB_SIMPLE,0,0)
			
	;create Fields
	Local fields=CreateBank(256*4)
	For i=1 To count
		PokeInt fields,4*(i-1),-1
	Next	
	SendMessageBANK(sb,SB_SETPARTS,count,fields)	
	FreeBank fields
	
	Return sb
End Function 

; ================================
; Set width of one field 
; ================================

;Note : width,style,tooltip are some optional parameters

Function SetStatusFieldWidth (sb,index,width=-1)
	Local SB_SETPARTS=$404
	Local SB_GETPARTS=$406
	
	;set width 
	Local fields=CreateBank(256*4)
	Local count=SendMessageBANK(sb,SB_GETPARTS,256,fields)
	
	If index>count-1 Then RuntimeError("The index is out of range")
	
	Local border=0
	If width<>-1
		If index=0 
			border=0	
		Else 
			border=PeekInt(fields,(index-1)*4)
		EndIf 
	EndIf 
	PokeInt fields,index*4,border+width
	SendMessageBANK(sb,SB_SETPARTS,count,fields)	
	FreeBank fields
		
End Function 

; ================================
; Change text of one field
; ================================

;Note : style and align are optional parameters
;Note : style=0 (flat) =1 (low border) =2 (high border)
;Note : align=0 left   =1 (right)      =2 (center)

Function SetStatusFieldText(sb,index,txt$,align=0,style=1)
	Local SB_SETTEXT=$401
    Local SBT_NOBORDERS=$100
	Local SBT_POPOUT=$200
	
	;set text
	Local fstyle
	Select style
		Case 0 
			fstyle = SBT_NOBORDERS
		Case 1 
			fstyle = 0  
		Case 2 
			fstyle = SBT_POPOUT
	End Select 		
	Select align
		Case 1 
			txt$ = Chr(9)+txt$  
		Case 2 
			txt$ = Chr(9)+txt$+Chr(9)
	End Select	
	SendMessageSTRING(sb,SB_SETTEXT,index Or fstyle,txt$)
End Function

Comments

TAS2008
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.


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


Code Archives Forum