Re: Making a scroll screen
Hi Limpit,
Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X < Frame1.Left Then
Frame1.Left = X
End If
If X > (Frame1.Left + Frame1.Width) Then
Frame1.Left = X - Frame1.Width
End If
If Y < Frame1.Top Then
Frame1.Top = Y
End If
If Y > (Frame1.Top + Frame1.Height) Then
Frame1.Top = Y - Frame1.Height
End If
End Sub
try this in a Form with a Frame !
Is this you want or something like that?
Re: Making a scroll screen
Yea sure...but how do i make the frame?
Re: Making a scroll screen
Frames are just one of the standard controls that you can drop onto your form. The Frame Control icon is located directly beneath the Textbox icon.
Frames are just containers - you can place controls inside them and if you move the frame, all the controls inside will move as well. Very useful things.
...
Re: Making a scroll screen
Yes, Dan is right.
Just an important thing about using Frames:
Quote:
Seeing the fact that Frames are container objects, the controls you want inside the Frames, you need to draw them manually inside the Frames. Just click the control once then click and drag it inside the frames.
If you were to just double click on a control, then move it inside the frame, it's not going to work, because the Form is also a Container object and every control double clicked in the toolbox, will be contained on the form.
You could also just Cut the control you want in the frame, then select the frame, then paste it in there!
Re: Making a scroll screen
Also, Rahul's code will move the frame around the form. If you want to create a scrolling effect, one method is the old dual picturebox technique.
Place a picturebox on a form, and then place a second picturebox inside the first. The inner picturebox can be any size you want - preferably much bigger than the outer picturebox. You can place controls or a picture in the second picturebox, then use the following code
Code:
Option Explicit
Private startX As Long, startY As Long
Private Sub Form_Load()
Me.ScaleMode = vbPixels
With picOuter
.ScaleMode = vbPixels
.AutoRedraw = True
.AutoSize = False
End With
With picInner
.ScaleMode = vbPixels
.AutoRedraw = True
.AutoSize = True
.BorderStyle = 0
.Move 0, 0
End With
'Change the picture path to load your own picture here
picInner.Picture = LoadPicture("C:\Documents and Settings\Dan\My Documents\My Pictures\splash7.jpg")
End Sub
Private Sub picInner_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
startX = X
startY = Y
End Sub
Private Sub picInner_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If startX > X Then picInner.Left = picInner.Left - 1
If startX < X Then picInner.Left = picInner.Left + 1
If startY > Y Then picInner.Top = picInner.Top - 1
If startY < Y Then picInner.Top = picInner.Top + 1
End If
End Sub
When you click and drag, the inner picturebox will move around inside the outer one, creating a scrolling impression.
...
Re: Making a scroll screen
Heres a little project i dumped a long while ago but it has exactly what your looking for..
Run it and dbl click on the text box at the top to Open a file.. Choose a relatively large image..
Left click on the image to move the image around.. move over the borders of the image to see the scrolling..
the code used is very simple..
SomeThing to note.. 'MouseMove' is only trigered when the mouse moves over the respective area.. if the mouse comes to a stop 'MouseMove' is called only once..
In this code a small 'Bug' (If we can call it that), Rather a Quirk is that the method i used for scrolling causes the 'MouseMove' event to be retrigerd.. give a nice smooth scroll..
Gremmy
Re: Making a scroll screen
Your project works quite nicely Gremlin, apart from the scroll bars, which are a bit buggy.
I have a version of the code I posted above that purely uses scroll bars to scroll the image - its more substantial than what I posted above, but also works beautifully.
...
Re: Making a scroll screen
I Agreed with Dan_H Also..
The Method is also a Beautiful way to scroll. !
1 Attachment(s)
Re: Making a scroll screen
wow thnx for the help guys...nice code gremlin...well I didnt exactly want the scroll bars for I used command buttons to scroll the screen... I just dont know how to make borders for the picture...look at my project:
1 Attachment(s)
Re: Making a scroll screen
Quote:
Originally Posted by limpit
wow thnx for the help guys...nice code gremlin...well I didnt exactly want the scroll bars for I used command buttons to scroll the screen... I just dont know how to make borders for the picture...look at my project:
The code you used isnt too bad but has a small Flaw.. if you move over the command on the left -move up to the top command then over to the right one.. you have 3 timers running.. doing: X + 100, Y + 100 and X - 100.. the image now makes a funny movement.. I've reposted my code with out scrollers (Just hid them actaully..)
Try it now..
Gremmy