Solved

How to click, hold and scroll a bitmap image

Posted on 2001-08-29
9
159 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
Comment Utility
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
Comment Utility
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
Comment Utility
Listening...
0
 

Expert Comment

by:newten
Comment Utility
listening too...(very interesting)
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:rbend
Comment Utility
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
Comment Utility
ArK:
oooopps...maybe I didn't read far enought...looks like your second code will do that...lemme check...
0
 

Author Comment

by:rbend
Comment Utility
of course...stupid me..
you did it exactly right.
0
 

Expert Comment

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

Expert Comment

by:Ark
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now