Solved

How to click, hold and scroll a bitmap image

Posted on 2001-08-29
9
165 Views
Last Modified: 2012-06-27
I have a form with the Acrobat Reader control on it.
Also on the form is an Image Control.

When I view a document with the Acrobat control, it has a nice feature that when you click on the document and hold the mouse button down, you can move (scroll) the document up or down on the page by moving the mouse.

I want to be able to do that with the document in the Image Control as well.

How do I do it?

0
Comment
Question by:rbend
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 27

Expert Comment

by:Ark
ID: 6438784
Hi
Use two picture boxes, one inside another. pbSource contain image, pbContainer is container for pbSource

Dim CurrentTop As Single
Dim yClick As Single

Private Sub Form_Load()
  pbSource.AutoSize = True
  pbSource.BorderStyle = 0
End Sub

Private Sub pbSource_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
   yClick = Y
End Sub

Private Sub pbSource_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Button = vbLeftButton Then
      CurrentTop = CurrentTop + Y - yClick
      pbSource.Move 0, CurrentTop
   End If
End Sub

Cheers
0
 
LVL 27

Accepted Solution

by:
Ark earned 100 total points
ID: 6438801
PS you can add same functionality for horizontal dragging, as well as add restriction not to drag outside image bounds:

Dim CurrentTop As Single, CurrentLeft As Single
Dim yClick As Single, xClick As Single

Private Sub Form_Load()
  pbSource.AutoSize = True
  pbSource.BorderStyle = 0
  pbSource.Move 0, 0
End Sub

Private Sub pbSource_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
   yClick = Y
   xClick = X
End Sub

Private Sub pbSource_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Button = vbLeftButton Then
      CurrentTop = CurrentTop + Y - yClick
      CurrentLeft = CurrentLeft + X - xClick
      If CurrentTop < pbContainer.Height - pbSource.Height Then CurrentTop = pbContainer.Height - pbSource.Height
      If CurrentTop > 0 Then CurrentTop = 0
      If CurrentLeft < pbContainer.Width - pbSource.Width Then CurrentLeft = pbContainer.Width - pbSource.Width
      If CurrentLeft > 0 Then CurrentLeft = 0
      pbSource.Move CurrentLeft, CurrentTop
   End If
End Sub

Cheers
0
 
LVL 2

Expert Comment

by:bhh
ID: 6438938
Listening...
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Expert Comment

by:newten
ID: 6439040
listening too...(very interesting)
0
 

Author Comment

by:rbend
ID: 6440260
Ark:

works like a charm.
I would only like it to scroll to the top or bottom of the actual image but I suppose that would be too much to ask you to add to your code?
0
 

Author Comment

by:rbend
ID: 6440281
ArK:
oooopps...maybe I didn't read far enought...looks like your second code will do that...lemme check...
0
 

Author Comment

by:rbend
ID: 6440291
of course...stupid me..
you did it exactly right.
0
 

Expert Comment

by:newten
ID: 6443188
Can you add how to display the acrobat's "Hand Icon" or any custom cursor whilst dragging????
0
 
LVL 27

Expert Comment

by:Ark
ID: 6443218
Thanks for points, glad I could help you. As for changing cursor:

Private Sub Form_Load()
    pbSource.AutoSize = True
    pbSource.BorderStyle = 0
    pbSource.Move 0, 0
'*******added**********
    pbSource.MousePointer = 99 'Custom
    pbSource.MouseIcon = LoadPicture("d:\vb50\graphics\cursors\hand.cur") 'Change to your path
End Sub

Private Sub pbSource_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    yClick = Y
    xClick = X
'*******added**********
    pbSource.MouseIcon = LoadPicture("d:\vb50\graphics\cursors\hand_move.cur") 'Change to your path
End Sub

Private Sub pbSource_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    pbSource.MouseIcon = LoadPicture("d:\vb50\graphics\cursors\hand.cur") 'Change to your path
End Sub

Cheers
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question