Dual Status in SysTray
Posted: Mon Oct 31, 2011 11:59 pm
Hi there,
while developing my DropMeFTP further, I added the following ProgressBar to the SysTray...
Feel free to use. I think, this will only work on Mac OS X, as the SysTray-Icon is 54x22 Pixels.
edit: Thanks, guys. Seems to work on Windows and Linux, too.
while developing my DropMeFTP further, I added the following ProgressBar to the SysTray...
Feel free to use. I think, this will only work on Mac OS X, as the SysTray-Icon is 54x22 Pixels.
edit: Thanks, guys. Seems to work on Windows and Linux, too.
Code: Select all
Global menuletimage
Global systray
Procedure Draw_On_Menulet(top.f,topsize.f,bottom.f,bottomsize.f)
If StartDrawing(ImageOutput(menuletimage))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0, 0,ImageWidth(menuletimage),ImageHeight(menuletimage),RGBA(0,0,0,0))
Box(2, 4,ImageWidth(menuletimage) - 4,6,RGBA(0,96,0,255))
Box(2,13,ImageWidth(menuletimage) - 4,6,RGBA(0,0,96,255))
Box(2, 4,top / topsize * (ImageWidth(menuletimage) - 4),6,RGBA(0,192,0,255))
Box(2,13,bottom / bottomsize * (ImageWidth(menuletimage) - 4),6,RGBA(0,0,192,255))
StopDrawing()
EndIf
ChangeSysTrayIcon(systray,ImageID(menuletimage))
SysTrayIconToolTip(systray, "Current file: " + Str(top) + " of " + Str(topsize) + #CR$ + "All files: " + Str(bottom) + " of " + Str(bottomsize))
EndProcedure
Procedure Create_Menulet_Bar(win,width,height)
menuletimage = CreateImage(#PB_Any, width + 4, height, 32)
If StartDrawing(ImageOutput(menuletimage))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,width + 4,height,RGBA(0,0,0,0))
StopDrawing()
EndIf
If Not IsSysTrayIcon(Systray)
Systray = AddSysTrayIcon(#PB_Any, WindowID(win), ImageID(menuletimage))
EndIf
EndProcedure
OpenWindow(0,100,100,100,100,"test")
Create_Menulet_Bar(0,50,22) ; create a Menulet for the Window 0 with Size width x height, e.g. 50,22
i = 0
j = 0
Repeat
j + Random(5)
If j >= 50
i + 5
j = 0
EndIf
; Draw and update the Menulet with j (top) and i (bottom), 50 is for setting the maximum width
; you may also insert 1234567 bytes of 987654 bytes. Try it
Draw_On_Menulet(j,50,i,50)
While WaitWindowEvent(10) : Wend
Delay(10)
Until i = 50