PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] scrolling image-VBForums
Results 1 to 10 of 10

Thread: [RESOLVED] scrolling image

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    133

    Resolved [RESOLVED] scrolling image

    I'm trying to scroll up and down some images when I push a button
    the images not scroll clearly

    Code:
     For X = 1 To 3
      fimg(X).Top = fimg(X).Top - 1
     Next X
    any suggestion?

  2. #2
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: scrolling image

    I'd suggest you reference a timer(clock) to move your images.

    That way you can determine where an image ought to be at a given time, and your program's performance can adapt to the system(like a frame skip).

    VB's built-in Timer function is probably good enough for this.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,234

    Re: scrolling image

    Also keep in mind the control's parent/container ScaleMode property. If the control is on a form and form's ScaleMode is Twips, simply subtracting 1 has little effect.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    133

    Re: scrolling image

    Can you give me a sample?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    133

    Re: scrolling image

    I tried to subtract 20 twips
    it scrolled faster but not clearly

  6. #6
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: scrolling image

    Here's an example project I've made to show you how to use a timer control along with a couple UDTs to handle moving an object according to a start/end location and time scale(seconds).

    If you have any problems with the code just post a reply.

    Add a timer, named: tMain; set the interval to 10, or more
    Add a Label(or Image control, or Picture, etc.), named: lPic, or rename it to your control

    vb Code:
    1. Private Type sngPoints
    2.   X As Single
    3.   Y As Single
    4. End Type
    5.  
    6. Private Type tAnimate
    7.   StartTime As Single
    8.     EndTime As Single
    9.    StartLoc As sngPoints
    10.      EndLoc As sngPoints
    11. End Type
    12.  
    13. Private animImage As tAnimate
    14.  
    15. Private Sub Form_Load()
    16.   Randomize
    17. End Sub
    18.  
    19. Private Sub tMain_Timer()
    20.  
    21.   Dim ElapsedPercent As Single
    22.  
    23.   With animImage
    24.     If Timer > animImage.EndTime Then
    25.         .StartTime = Timer
    26.         .EndTime = Timer + 3 * Rnd
    27.         .StartLoc.X = lPic.Left
    28.         .StartLoc.Y = lPic.Top
    29.         .EndLoc.X = ScaleWidth * Rnd
    30.         .EndLoc.Y = ScaleHeight * Rnd
    31.     End If
    32.     ElapsedPercent = (Timer - .StartTime) / (.EndTime - .StartTime)
    33.     lPic.Move .StartLoc.X + (.EndLoc.X - .StartLoc.X) * ElapsedPercent, _
    34.               .StartLoc.Y + (.EndLoc.Y - .StartLoc.Y) * ElapsedPercent
    35.   End With
    36.  
    37. End Sub

    This example moves the control around the form randomly.
    Attached Files Attached Files

  7. #7
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: scrolling image

    If all images always scroll the same amount and are next to each other, you could use a single container control such as a borderless Frame and move that single control. All the children remain in the same position, only the container needs to move.


    Also, setting ScaleMode to vbPixels for the container's parent control (such as a Form or a PictureBox) will make moving by 1 more visible. One twip (the default unit for ScaleMode) is 1/15 of a pixel (ie. 15 twips = 1 pixel). Scrolling by 1 pixel may be slow though, if you need more speed then you want to move by larger values.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    133

    Re: scrolling image

    thanks
    but there is no possible to download the attached filed

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    133

    Re: scrolling image

    thanks merri
    that's works great

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Posts
    133

    Re: scrolling image

    thanks firextol

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width