hi all,
1. how can i check the picture control is empty
2. Is it possible to insert scroll bar(horizonatl and veritcal) with picture control so that i can scroll i see the complete image inserted
thanks in advance
saj
Printable View
hi all,
1. how can i check the picture control is empty
2. Is it possible to insert scroll bar(horizonatl and veritcal) with picture control so that i can scroll i see the complete image inserted
thanks in advance
saj
1. To check if there is a picture in the Picturebox you can use..
The image in the picturebox is different, it's always there but it's not possible to know if there is something drawn (image is not the same than picture here), the image contains what you draw or paint manually inside the picturebox canvas. The answer to your question (2) here uses the image, not the picture, but you can easily copy the image to picture:VB Code:
If Picture1.Picture = 0 Then MsgBox "No picture loaded" Else MsgBox "there is a picture loaded" End If
VB Code:
Set Picture1.Picture = Picture1.Image
2. Add a VScroll1 and a HScroll to your Form
In this example i loaded the picture by code but it can be changed to work with a picture loaded in design mode.
VB Code:
Private mPic As Picture Private mWidth As Long Private mHeight As Long Private Sub Form_Load() With Picture1 .ScaleMode = vbPixels .AutoRedraw = True Set mPic = LoadPicture("D:\chory.jpg") '(Load your picture in this line) mWidth = ScaleX(mPic.Width, vbHimetric, vbPixels) mHeight = ScaleX(mPic.Height, vbHimetric, vbPixels) .PaintPicture mPic, 0, 0 End With If mHeight > Picture1.ScaleHeight Then With VScroll1 .Min = 0 .Max = mHeight - Picture1.ScaleHeight .SmallChange = ((mHeight - Picture1.ScaleHeight) / 100) + 1 .LargeChange = ((mHeight - Picture1.ScaleHeight) / 10) + 1 End With Else VScroll1.Enabled = False End If If mWidth > Picture1.ScaleWidth Then With HScroll1 .Min = 0 .Max = mWidth - Picture1.ScaleWidth .SmallChange = ((mWidth - Picture1.ScaleWidth) / 100) + 1 .LargeChange = ((mWidth - Picture1.ScaleWidth) / 10) + 1 End With Else HScroll1.Enabled = False End If End Sub Private Sub HScroll1_Change() RedrawPic End Sub Private Sub VScroll1_Change() RedrawPic End Sub Private Sub RedrawPic() With Picture1 .Cls .PaintPicture mPic, -HScroll1.Value, -VScroll1.Value End With End Sub
If Picture1.Picture.Width = 0 Then 'EmptyQuote:
Originally Posted by sajankk