|
-
Jan 2nd, 2007, 09:00 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Problem to stretch picture in picturebox
I cannot stretch picture loaded in a picturebox according to picturebox scale. I don't know what is the problem with this code. Can anybody help me find the problem?
VB Code:
Private Sub picPatient_Click()
On Error Resume Next
Dim sPathPic As String, currentID As Long
If rec("img_path") = "" Then
If MsgBox("Do you want to add picture?", vbYesNo + vbQuestion, "Add picture") = vbYes Then
'Add picture here
cdOpen.Filter = "JPEG |*.jpg"
cdOpen.ShowOpen
sPathPic = Replace(cdOpen.FileName, "\", "\\")
con.Execute "UPDATE maklumat_pesakit img_path SET img_path = '" & sPathPic & "' WHERE id = " & rec(0) & ";"
currentID = CLng(rec(0))
Form_Load
rec.Find "[ID] = " & currentID
Exit Sub
End If
Else
If MsgBox("Do you want to remove this picture?", vbYesNo + vbQuestion, "Remove picture") = vbYes Then
con.Execute "UPDATE maklumat_pesakit img_path SET img_path = '' WHERE id = " & rec(0) & ";"
Set picPatient.Picture = Nothing
currentID = CLng(rec(0))
Form_Load
rec.Find "[ID] = " & currentID
Exit Sub
End If
End If
End Sub
Private Sub picPatient_Resize()
picPatient.PaintPicture picPatient.Picture, 0, 0, picPatient.ScaleWidth, picPatient.ScaleHeight
End Sub
-
Jan 2nd, 2007, 09:08 PM
#2
Re: Problem to stretch picture in picturebox
Try putting it into the paint event
VB Code:
Private Sub picPatient_Paint()
picPatient.PaintPicture picPatient.Picture, 0, 0, picPatient.ScaleWidth, picPatient.ScaleHeight
End Sub
-
Jan 2nd, 2007, 09:13 PM
#3
Thread Starter
Hyperactive Member
Re: Problem to stretch picture in picturebox
I tried to put it into paint event but "Argument not optional" error msg appear
-
Jan 2nd, 2007, 09:19 PM
#4
Re: Problem to stretch picture in picturebox
Worked perfectly for me ...
It will bring up an error if there is no image in the picturebox, but i'm not sure why its bringing up the "Argument not optional" error (the error for no picture is "Invalid Picture")
Does it highlight any part of the code?
Also make sure all required arguments aren't missing... maybe something might have been removed by accident
Code:
object.PaintPicture picture, x1, y1, [width1], [height1], [x2], [y2], [width2], [height2], [opcode]
You can omit as many optional trailing arguments as you want. If you omit an optional trailing argument or arguments, don't use any commas following the last argument you specify. If you want to specify an optional argument, you must specify all optional arguments that appear in the syntax before it.
[Optional argument]
Last edited by Andrew G; Jan 2nd, 2007 at 09:24 PM.
-
Jan 2nd, 2007, 09:30 PM
#5
Thread Starter
Hyperactive Member
Re: Problem to stretch picture in picturebox
Thanks andrew, it works now. I actually put , , to x1 and y1 arguments that's why it erroring. Ok thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|