-
I've got an app that does a screen grab then puts it into a picturebox. I need to put two scroll bars on the picturebox so I can see the whole screen (I don't really want to scale it down so it fits)
How can I link HScroll and VScroll to a picturebox?
-
Do you mean so that when you move the scrollbar the image will shrink horizontally or vertically? If so then this should work:
In the scrollbars change procedure put something like this.
Picture1.Width = ScrollBar1.Value
Picture1.Height = ScrollBar2.Value
Have a good one ;)
David Richardson
-
I think what Simonp is trying to do is, if the image is too big to fit into the picture box then the scroll bar will move the image up or down to view all the image. Like a paint program i.e. PaintShop Pro
------------------
rino_2
Visual Basic, HTML
-
Use two picture boxes. Put one inside the other (so the other one is the container). Set the AutoSize property of the one that is inside. Now when the values in the HScroll and the VScroll changes just move the inner picture box.
Good luck!
------------------
Joacim Andersson
[email protected]
[email protected]
www.YellowBlazer.com
-
There are 3 ways to scroll a picture:
using containers:
Private Sub Form_Load()
flag = False
Picture2.Move 0, 0
ScrollMax = Picture1.Width - Picture2.Width
direction = -1
i = 0
Show
End Sub
Sub Scroll(Index As Integer)
Static i%
flag = Not flag
While flag
DoEvents
i = i + direction
Picture2.Move i
If i = 0 Or i = ScrollMax Then direction = -direction
Wend
End Sub
Picture2 is to be scrolled. Picture1 is the container.
using BitBlt:
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function ScrollDC Lib "user32" (ByVal hdc As Long, ByVal dx As Long, ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hrgnUpdate As Long, lprcUpdate As RECT) As Long
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Global Const SRCCOPY = &HCC0020
Public Type Scale
length As Integer
height As Integer
End Type
Dim hDestDC&
Dim hSourceDC&
Dim Bild As Scale
Dim ScrollMax&
Dim i As Integer
Dim direction As Integer
Dim flag%
Private Sub Form_Load()
flag = False
Picture.length = Picture1.Width - 1
Picture.height = Picture1.Height
ScrollMax = Picture2.ScaleWidth
direction = 1
i = Picture1.length + 1
Show
hDestDC = Picture1.hdc
hSourceDC = Picture2.hdc
Call BitBlt(hDestDC, 0, 0, Picture.Length + 1, Picture.Height, hSourceDC, 0, 0, SRCCOPY)
End Sub
Private Sub Scroll(Index As Integer)
flag = Not flag
While flag
' If i Mod 50 = 0 Then DoEvents
DoEvents
i = i + 1
Call BitBlt(hDestDC, 0, 0, Picture.length, Picture.Height, hDestDC, 1, 0, SRCCOPY)
Call BitBlt(hDestDC, Picture.length, 0, 1, Picture.Height, hSourceDC, i, 0, SRCCOPY)
If i = ScrollMax Then i = 0
Wend
End Sub
using ScrollDC:
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function ScrollDC Lib "user32" (ByVal hdc As Long, ByVal dx As Long, ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hrgnUpdate As Long, lprcUpdate As RECT) As Long
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Global Const SRCCOPY = &HCC0020
Dim Upd As Integer
Dim hDestDC&
Dim hSourceDC&
Dim Scrollfield As RECT
Dim destroy As RECT
Dim Picture As Maße
Dim ScrollMax As Integer
Dim i As Integer
Dim flag%
Private Sub Form_Load()
flag = False
Picture.Length = Picture1.Width
Picture.Height = Picture1.Height
Scrollfield.Right = Picture.Length
Scrollfield.Bottom = Picture.Height
ScrollMax = Picture2.Width
i = Picture.Length
Show
hDestDC = Picture1.hdc
hSourceDC = Picture2.hdc
Call BitBlt(hDestDC, 0, 0, Picture.Length, Picture.Height, hSourceDC, 0, 0, SRCCOPY)
End Sub
Sub Scroll(Index as Integer)
Static i%
flag = Not flag
While flag
If i Mod 50 = 0 Then DoEvents
' DoEvents
i = i + 1
ScrollDC hDestDC, -1, 0, Scrollfield, Scrollfield, Upd, destroy
Call BitBlt(hDestDC, destroy.Left, 0, 1, Picture.Height, hSourceDC, i, 0, SRCCOPY)
If i = ScrollMax Then i = 0
Wend
End Sub
ScrollDC is the fasted way
------------------
Razzle
ICQ#: 31429438
[This message has been edited by Razzle (edited 02-06-2000).]
-
then you can link the scrollbars to one of those functions
------------------
Razzle
ICQ#: 31429438
What is the difference between a raven?
-The legs. The length is equal, especially the right one. :D
-
Hey Razzle,
I'm really stuggling getting this working :)
This is about the hardest thing I've done yet - could you jot down a few idiot points?!
Thanks
Simon
-
I've sent you a demo app that uses a picturebox within a picturebox that's relatively easy to implement.
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"