This code doesn't accomplish much in and of itself but if someone wanted to use it as the basis for a status bar for jobs that take time it would work well for that. Maybe put a ProgressBar gadget on it. Or you could put icons on it for a toolbar, or wire links into the menu. It's a starting point really for a number of possibilities. I just made it for fun, thought it was cool and so I'm sharing it. Hope you like it.
Code: Select all
Enumeration
#windowmain
#windowimage
#closebutton
#buttonimage
#hotbuttonimage
#menuclose
EndEnumeration
Global windowalpha = 70
Global Days$="Sun Mon Tue Wed Thu Fri Sat"
Global months$="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
Procedure Fadein()
While windowalpha < 220
windowalpha+10
SetLayeredWindowAttributes_(WindowID(#windowmain),0,windowalpha,#LWA_ALPHA)
Delay(1)
Wend
EndProcedure
Procedure Fadeout()
While windowalpha > 70
windowalpha-10
SetLayeredWindowAttributes_(WindowID(#windowmain),0,windowalpha,#LWA_ALPHA)
Delay(1)
Wend
EndProcedure
Procedure ProcessHotSpots()
Select ChildWindowFromPoint_(WindowID(#windowmain),(WindowMouseX(#windowmain) & $FFFFFFFF) | (WindowMouseY(#windowmain)) << 32);,,
Case GadgetID(#closebutton)
SetGadgetState(#closebutton, ImageID(#hotbuttonimage))
Case WindowID(#windowmain)
SetGadgetState(#closebutton, ImageID(#buttonimage))
EndSelect
EndProcedure
CreateImage(#windowimage,400,28)
StartDrawing(ImageOutput(#windowimage))
Line(0,0,1,28,#Black)
Line(399,0,1,28,#Black)
For j=1 To 398
Restore windowface
For i=0 To 27
Read color
Plot(j,i,color)
Next
Next
StopDrawing()
GrabImage(#windowimage,#buttonimage,370,6,20,18)
StartDrawing(ImageOutput(#buttonimage))
DrawingMode(3)
DrawText(6,1,"X",RGB(160,20,160))
StopDrawing()
GrabImage(#windowimage,#hotbuttonimage,370,6,20,18)
StartDrawing(ImageOutput(#hotbuttonimage))
DrawingMode(3)
DrawText(6,1,"X",#White)
DrawText(7,1,"X",#White)
StopDrawing()
ExamineDesktops()
OpenWindow(#windowmain,DesktopWidth(0)-440,DesktopHeight(0)/2-10,400,28,"",#PB_Window_BorderLess)
ShowWindow_(WindowID(#windowmain),#SW_HIDE)
SetWindowLong_(WindowID(#windowmain),#GWL_EXSTYLE,GetWindowLong_(WindowID(#windowmain),#GWL_EXSTYLE)|#WS_EX_LAYERED|#WS_EX_TOOLWINDOW)
SetLayeredWindowAttributes_(WindowID(#windowmain),0,windowalpha,#LWA_ALPHA)
ShowWindow_(WindowID(#windowmain),#SW_SHOW)
StickyWindow(#windowmain,1)
SmartWindowRefresh(#windowmain,1)
ImageGadget(#closebutton,370,5,20,18,ImageID(#buttonimage))
CreatePopupMenu(0)
MenuItem(1, "Do valuable task #one")
MenuItem(2, "Do valuable task #two")
MenuItem(3, "Do valuable task #three")
MenuItem(#menuclose, "Close the toolbar")
quit=0
time=ElapsedMilliseconds()
Repeat
day$=StringField(days$,DayOfWeek(Date())+1," ")+" "
mon$=StringField(months$,Month(Date())," ")+" "
If Hour(Date())<12
ampm$="am"
hour=Hour(Date())
Else
ampm$="pm"
hour=Hour(Date())-12
EndIf
hour$=Str(hour)+ ":"
daynum$=Str(Day(Date()))+" "
min$=RSet(Str(Minute(Date())),2,"0")+" "
date$=day$+mon$+daynum$+hour$+min$+ampm$
If ElapsedMilliseconds()-time >= 5000
time=ElapsedMilliseconds()
InvalidateRgn_(WindowID(#windowmain),0,0)
EndIf
EventID=WaitWindowEvent(1)
Select EventID
Case #PB_Event_ActivateWindow, #WM_PAINT
StartDrawing(WindowOutput(#windowmain))
DrawImage(ImageID(#windowimage),0,0)
DrawingMode(3)
DrawText(10,5, date$ )
StopDrawing()
InvalidateRgn_(WindowID(#windowmain),0,0) ;uncomment if gadgets exist
UpdateWindow_(WindowID(#windowmain))
Case #WM_LBUTTONDOWN
SendMessage_(WindowID(#windowmain), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
Case #WM_RBUTTONDOWN
DisplayPopupMenu(0, WindowID(#windowmain))
Case #PB_Event_Menu
Select EventMenu()
Case #menuclose
quit=1
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #closebutton
quit = 1
EndSelect
EndSelect
If DesktopMouseX()>=WindowX(#windowmain) And DesktopMouseX()<=WindowX(#windowmain)+ImageWidth(#windowimage)
If DesktopMouseY()>=WindowY(#windowmain) And DesktopMouseY()<=WindowY(#windowmain)+ImageHeight(#windowimage)
Fadein()
Else
Fadeout()
EndIf
Else
Fadeout()
EndIf
ProcessHotSpots()
Until quit
End
DataSection
windowface:
Data.l $0,$C0BBC9,$BEB8C9,$BEB5C9,$BCB1C9,$BAADC9,$B9A9C9,$B7A5C9,$B6A0C7,$B49CC8,$B297C7,$B092C7,$AD8DC7,$AC87C6
Data.l $A982C6,$A87DC5,$A578C5,$A372C5,$A16CC4,$9F67C4,$9D63C3,$9B5DC3,$9959C2,$9754C2,$954FC2,$944BC1,$9347C1,$0
EndDataSection
Code: Select all
Dim colors.s(28)
LoadImage(0,"windowface.bmp")
StartDrawing(ImageOutput(0))
For i = 0 To 27
colors(i)="$"+Hex(Point(5,i))
Next
StopDrawing()
CreateFile(0,"windowface.pbi")
WriteStringN(0,"DataSection")
WriteStringN(0," windowface:")
WriteString(0," Data.l ")
For i = 0 To 12
WriteString(0,colors(i)+",")
Next
WriteStringN(0,colors(13))
WriteString(0," Data.l ")
For i = 14 To 26
WriteString(0,colors(i)+",")
Next
WriteStringN(0,colors(27))
WriteStringN(0,"EndDataSection")
CloseFile(0)