Solved

How to click, hold and scroll a bitmap image

Posted on 2001-08-29
9
166 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

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!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

726 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