Solved

How to click, hold and scroll a bitmap image

Posted on 2001-08-29
9
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 28

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 28

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 28

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 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