Solved

How to click, hold and scroll a bitmap image

Posted on 2001-08-29
9
160 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
 

Expert Comment

by:newten
ID: 6439040
listening too...(very interesting)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

919 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

12 Experts available now in Live!

Get 1:1 Help Now