
nomainwin
'statusbar parts:
'0=changing text
'1=Window Title
'2=Numberlock On/Off
'3=Ins On/Off
'4=time
' Open window
WindowWidth=600:WindowHeight=150
button #1, "Update",[update],UL,10,10,100,30
open "StatusBar Test" for window as #1
print #1, "trapclose [quit]"
print #1, "resizehandler [size]"
' Init common controls
calldll #comctl32, "InitCommonControls", _
re as void
hStatus=StatusBar(hwnd(#1), "Changing Text")
call SetParts hStatus
Call SetText hStatus,1,"StatusBar Test"
Call SetText hStatus,4,time$()
timer 1000, [changeTime]
wait
[changeTime]
Call SetText hStatus,4,time$()
numLock=GetKeyState(_VK_NUMLOCK)
if numLock=0 then
call SetText hStatus, 2, "NUM OFF"
else
call SetText hStatus, 2, "NUM ON"
end if
insLock=GetKeyState(_VK_INSERT)
if insLock=0 then
call SetText hStatus, 3, "INS OFF"
else
call SetText hStatus, 3, "INS ON"
end if
wait
[update]
updateTotal=updateTotal+1
update$="Message updated ";str$(updateTotal);" times."
call SetText hStatus,0,update$
wait
[size]
calldll #user32, "SendMessageA",_
hStatus as ulong,_WM_SIZE as long,_
0 as long, WindowWidth as long,_
re as long
wait
[quit]
calldll #user32, "SendMessageA",_
hStatus as word,_WM_DESTROY as word,_
0 as word,0 as long,re as long
close #1:end
Function StatusBar(hWnd, txt$)
style = _WS_VISIBLE or _WS_CHILD
calldll #comctl32, "CreateStatusWindow",_
style as long,_ 'window style
txt$ as ptr,_ 'desired caption
hWnd as long,_ 'handle of parent window
10 as word,_ 'ID, not used by LB
StatusBar as ulong 'returns handle of status bar
End Function
Sub SetParts hWnd
SB.SETPARTS = 1028
struct prt,edge1 as long, edge2 as long,_
edge3 as long,edge4 as long,edge5 as long
prt.edge1.struct=180
prt.edge2.struct=300
prt.edge3.struct=380
prt.edge4.struct=460
prt.edge5.struct=-1
numParts=5
calldll #user32, "SendMessageA",_
hWnd as ulong, SB.SETPARTS as long,_
numParts as long,prt as struct,r as long
End Sub
Sub SetText hWnd,segID,txt$
SB.SETTEXT = 1025
calldll #user32, "SendMessageA",_
hWnd as ulong,SB.SETTEXT as long,_
segID as long,txt$ as ptr,r as long
End Sub
Function GetKeyState(key)
CallDLL #user32, "GetKeyState",key As long,_
GetKeyState As long
End Function