Microsoft Small Basic

Program Listing: BLS788
' Desktop Sample Program
' Version 0.1
' Copyright © 2016 Nonki Takahashi. The MIT License.
'
GraphicsWindow.Title = "Desktop Sample Program 0.1"
Not = "False=True;True=False;"
dw = Desktop.Width
dh = Desktop.Height
Form()
NextPhoto()
While "True"
If buttonClicked Then
If Controls.LastClickedButton = btnNext Then
NextPhoto()
ElseIf Controls.LastClickedButton = btnSet Then
Desktop.SetWallPaper(url)
EndIf
buttonClicked = "False"
EndIf
EndWhile
Sub NextPhoto
tag = Controls.GetTextBoxText(tboxTag)
url = Flickr.GetRandomPicture(tag)
img = ImageList.LoadImage(url)
iw = ImageList.GetWidthOfImage(img)
Shapes.SetText(txtIw, iw)
ih = ImageList.GetHeightOfImage(img)
Shapes.SetText(txtIh, ih)
Shapes.Remove(photo)
photo = Shapes.AddImage(img)
Shapes.Move(photo, 10, 70)
EndSub
Sub Form
' param dw - desktop width
' param dh - desktop height
GraphicsWindow.Width = 520
GraphicsWindow.Height = 580
GraphicsWindow.BackgroundColor = "#333333"
GraphicsWindow.BrushColor = "Black"
btnNext = Controls.AddButton("Next", 10, 38)
btnSet = Controls.AddButton("SetWallPaper", 60, 38)
tboxTag = Controls.AddTextBox(40, 10)
Controls.SetTextBoxText(tboxTag, "toys")
GraphicsWindow.BrushColor = "White"
GraphicsWindow.DrawText(10, 13, "Tag")
GraphicsWindow.DrawText(220, 13, "Desktop.Width =")
txtDw = Shapes.AddText(dw)
Shapes.Move(txtDw, 327, 13)
GraphicsWindow.DrawText(376, 13, "Desktop.Height =")
txtDh = Shapes.AddText(dh)
Shapes.Move(txtDh, 487, 13)
GraphicsWindow.DrawText(220, 43, "Image Width =")
txtIw = Shapes.AddText("")
Shapes.Move(txtIw, 327, 43)
GraphicsWindow.DrawText(376, 43, "Image Height =")
txtIh = Shapes.AddText("")
Shapes.Move(txtIh, 487, 43)
Controls.ButtonClicked = OnButtonClicked
EndSub
Sub OnButtonClicked
buttonClicked = "True"
EndSub