screenWidth=1280
screenHeight=800
printX=550
printY=20
p$="Location of folder with images"
set dir p$
a=0
do
t$=str$(a)+".bmp"
if path exist(t$)
a=a+1
else
exit
endif
loop
a=a-1
a=rnd(a)
image$=str$(a)+".bmp"
set display mode screenWidth, screenHeight, 32, 1
`============================================
load image image$, 1, 1
paste image 1, 0, 0
date$=get date$()
month=val(left$(date$, 2))
date$=right$(date$, len(date$)-3)
day=val(left$(date$, 2))
year$=right$(date$, 2)
year$="20"+year$
year=val(year$)
set text size 30
ink rgb(0, 0, 150), rgb(0, 0, 0)
select month
case 1 : center text printX+90, printY, "January" : max=31 : maxt=31 : endcase
case 2 : center text printX+90, printY, "February" : max=28 : maxt=31 : endcase
case 3 : center text printX+90, printY, "March" : max=31 : maxt=28 : endcase
case 4 : center text printX+90, printY, "April" : max=30 : maxt=31 : endcase
case 5 : center text printX+90, printY, "May" : max=31 : maxt=30 : endcase
case 6 : center text printX+90, printY, "June" : max=30 : maxt=31 : endcase
case 7 : center text printX+90, printY, "July" : max=31 : maxt=30 : endcase
case 8 : center text printX+90, printY, "August" : max=31 : maxt=31 : endcase
case 9 : center text printX+90, printY, "September" : max=30 : maxt=31 : endcase
case 10 : center text printX+90, printY, "October" : max=31 : maxt=30 : endcase
case 11 : center text printX+90, printY, "November" : max=30 : maxt=31 : endcase
case 12 : center text printX+90, printY, "December" : max=31 : maxt=30 : endcase
endselect
set text size 20
center text printX, printY+40, "S"
center text printX+30, printY+40, "M"
center text printX+60, printY+40, "T"
center text printX+90, printY+40, "W"
center text printX+120, printY+40, "T"
center text printX+150, printY+40, "F"
center text printX+180, printY+40, "S"
one=CalcDayOfWeek(20, year, month, 1)
start=maxt-(one-2)
if one>5
rows=6
else
rows=5
endif
b=1
for row=1 to rows
for a=1 to 7
if a<one
ink rgb(150, 0, 0), rgb(0, 0, 0)
temp$=str$(start)
center text (printX-30)+(a*30), printY+40+(row*20), temp$
start=start+1
else
ink rgb(255, 255, 255), rgb(0, 0, 0)
temp$=str$(b)
if b>max
ink rgb(150, 0, 0), rgb(0, 0, 0)
c=b-max
temp$=str$(c)
endif
if b=day
ink rgb(190, 190, 0), rgb(0, 0, 0)
endif
center text (printX-30)+(a*30), printY+40+(row*20), temp$
b=b+1
endif
next a
one=1
next row
get image 2, 0, 0, screenWidth, screenHeight, 1
save image "temp.bmp", 2
p$=p$+"temp.bmp"
load dll "user32.dll", 1
call dll 1, "SystemParametersInfoA", 20, 0, p$, 0
delete dll 1
end
function CalcDayOfWeek(Century, Year, Month, Day)
local Holder
if Month < 3
inc Month, 12
if Year > 0
dec Year
else
Year = 99
dec Century
endif
endif
Holder = Day
Holder = Holder + (((Month + 1) * 26) / 10)
Holder = Holder + Year
Holder = Holder + (Year / 4)
Holder = Holder + (Century / 4)
Holder = Holder - Century - Century
while Holder < 0
inc Holder + 7
endwhile
Holder = Holder mod 7
if Holder = 0 then Holder = 7
dec Holder
endfunction Holder
This code will, when run, select a random desktop image paste a calandar on it, and set your desktop to that image.
To set this up, I would copy the code into DBPro and first edit the top few variables. The Screen Width and Screen Height, obviously, you need to set those to your desktop resolution. The PrintX and PrintY variables is the location of the top left corner of the calendar, so you can have the calendar printed anywhere you like. I like it at the top in center. Then finally to set it up you will need to create a folder anywhere you like and put as many images in the folder as you want.
Images must be named like this: 0.bmp 1.bmp 2.bmp 3.bmp..... This way you can easily add images without having to change the code at all. One other thing, All images must be the proper size of your desktop, or it may not show up properly.
After you do all that, I would set the executable to run 'hidden', then press F5. It will be compiled to the TEMP folder in you DBPro folder, just take it out and put it somewhere. If you want this program to run everytime you turn on your computer (to keep an updated calendar) simply put the program in your startup folder. If you can't find the startup folder check the next post on this thread, and I will explain a different way.
Anyone is welcome to use this code however you like. You can easily change the colors of the calendar, or add a transparent square behind. If you don't like it selecting a random image then it should also be easy for you to change that. You may also wish to be able to use images that aren't of your desktop resolution, in this case, I would open the image in PAINT or other software and change that. Or you could edit the code to load the image as a bitmap and scale it properly.
Currently there is only one minow issue with this. It cannot be fixed with code. The issue is that when you start up your computer it will display your old background for a while before the program runs again. To fix this just run the code at least once, and manually set your desktop to the "temp.bmp" image created by the program in your image folder.
The right man in the wrong place can make all the difference in the world.