Microsoft Small Basic

Program Listing: PWW374
title = "Flicr Sample"
GraphicsWindow.Title = title
Not = "True=False;False=True;"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "#333333"
GraphicsWindow.FontName = "Trebuchet MS"
GraphicsWindow.MouseDown = OnMouseDown
While "True"
GraphicsWindow.Clear()
GraphicsWindow.Title = title
GraphicsWindow.BrushColor = "White"
GraphicsWindow.DrawText(260, 200, "Loading...")
url = Flickr.GetPictureOfMoment()
GraphicsWindow.BrushColor = "Black"
tbox = Controls.AddTextBox(10, 400)
Controls.SetSize(tbox, gw - 20, 22)
Shapes.SetOpacity(tbox, 50)
Controls.SetTextBoxText(tbox, url)
GraphicsWindow.Title = title + " - " + url
img = ImageList.LoadImage(url)
iw = ImageList.GetWidthOfImage(img)
ih = ImageList.GetHeightOfImage(img)
gwph = gw / gh
iwph = iw / ih
If gwph < iwph Then
scale = gw / iw
x = 0
y = Math.Floor((gh - ih * scale) / 2)
Else
scale = gh / ih
x = Math.Floor((gw - iw * scale) / 2)
y = 0
EndIf
GraphicsWindow.DrawResizedImage(img, x, y, iw * scale, ih * scale)
mouseDown = "False"
While Not[mouseDown]
Program.Delay(300)
EndWhile
EndWhile
Sub OnMouseDown
mouseDown = "True"
EndSub