I am getting an exception error on the // scaledown if statement which triggers a paint event on the image “MainImg” ( canvas ), i have marked the error line as this << .
It is an exception error with the REALbasic.Rect(-1) which i am not sure what the means.
MainImage is a global string property which is the name of the image.
The puzzling thing is this has been working fine with no problems for maybe 1/2 year , until today. as far as i know i have changed nothing.
here is the code below
please advise
[code]dim f as FolderItem
dim p as Picture
Dim nW, nH as integer
Dim ratio as Integer
if MainWin.DBLocation.Text = “” then
Return
End if
if MainImage = “” then
MsgBox “Main Image Not Set”
return
end if
f = MainWin.PictureFolder.Child(MainImage)
if f = Nil or Not f.Exists Then
Status1.Text = “Photo " + MainImage + " not found”
return
End if
p = f.OpenAsPicture
//msgBox Str(p.Height)
// scaledown
if p.Height > 800 then << Exception Error Here /
ratio = p.Height - 400
end if
nW = p.Width - ratio
nH = p.Height - ratio
g.ForeColor= &c000000
g.DrawRect 0,0,Me.width,Me.height
g.DrawPicture(p,0,0, nW ,nH ,0,0,p.Width,p.Height)[/code]
I tried
//p = f.OpenAsPicture
p = Picture.Open(f)
but got the same exception
The photo is a .JPG taken by a cannon. I drag and drop the photo on to my “thumb” canvas, it this reads the name of the photo, gets the location, sets the FolderItem location, then attempts to open the picture with f.OpenAsPicture OR picture.open(f)
below is the drag and drop event
[code]Dim DropImgPath As FolderItem
Dim ImageName As String = MainWin.ItemCode.Text + “-” + format(index+1, “00”) + “.jpg”
Dim rtn as string
If obj <> Nil Then
// copy full size image to _DB
DropImgPath = obj.FolderItem
DropImgPath.CopyFileTo(MainWin.PictureFolder.Child(ImageName))
if index = 0 then // refresh the 1st Image
MainWin.ItemID = MainWin.ItemCode.text
if MainWIn.ItemID <> “” then
MainWin.Canvas1.Refresh
end if
end if[/code]
very simple. a Msgbox takes focus away from the window… when you dismiss it, the window gets focus back, which in turn fires the Paint event, which may display the Msgbbox again, which takes focus away from the window … [add recursion here]