Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Moving A Image


How can i move an image left and right???I would imagine its simple but i suck at vb well i will apreciate the help ty!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving An Image To Move Another Image
Im creating my first small program for my assignment and ive done the design and code, just havign trouble with another part if anyone could help me please.

Here is my whole code first off.


Code:
Option Explicit

Private Sub cmdBat_Click()

While imgBall.Left < imgBatter.Left
'Moves the ball away from the bowler
imgBall.Left = imgBall.Left + 1
'Comment
DoEvents
Wend
'Comment
While imgBall.Left < imgBatter.Left
'Comment
imgBall.Top = imgBall.Top - 1
'Comment
imgBall.Left = imgBall.Left
' Allows the user to respond to another button
DoEvents
Wend
End Sub

Private Sub cmdBowl_Click()

While imgBall.Left < imgBowler.Left
' Moves the ball towards the batter
imgBall.Left = imgBall.Left - 1
' Allows the user to respond to another button
DoEvents
Wend
'Comment
While imgBall.Left < imgBowler.Left
'Comment
imgBall.Top = imgBall.Top + 1
'Comment
imgBall.Left = imgBall.Left
'Comment
DoEvents
Wend

End Sub

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdStart_Click()
imgBowler.Left = 8400
imgBowler.Top = 960
imgBatter.Left = 840
imgBatter.Top = 960
imgBall.Left = 7920
imgBall.Top = 2520
End Sub
What i need to do, as the ball gets to the bat for the bat to hit the ball and move it back where it came from. Ive done so far that the ball goes past the batter and when the bat button is pressed the ball comes back to the bat and goes back again.

I cant work out how to move the ball back when the ball is moving and the button is pressed. Im not advanced in programing either, ive been doing it for about a year

Here is an EXE of the program so far to demonstate
<link removed>

Image Moving
vb6.0
Hi,

id like to know how to move a picture inside an picture box without moving the box but only the picture inside it. like, i have a 2000x2000 picture in a 400x400 picture box and wat i want is for it to show inside it and then i move the picture to see differ parts of it while the picture box remains in the same place.


Thank you.

Seeing The Image While Moving It
How to move an Image (or a PictureBox) over a Form and see the image, not only its surrounding frame, during the move phase. Basically, my code looks as follows:

[vbtemp]
Private Xi As Single
Private Yi As Single

Private Sub Card_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Card(Index).Drag vbBeginDrag
Xi = X
Yi = Y
End If
End Sub

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move X - Xi, Y - Yi
End Sub

Private Sub Card_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
Source.Move Source.Left + X - Xi, Source.Top + Y - Yi
End Sub
[/vbtemp]

The 'Card' is an Image (or a PictureBox) located in a control array. The code works fine, but I can't see the card face while I'm moving it.

Moving An Image
I tried borrowing the code from ?????'s pacman example

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'figure out where we WANT to go....
Select Case KeyCode
Case vbKeyLeft:
ShpTestShooter.Move -350
Case vbKeyRight:
ShpTestShooter.Move 350
End Select
End Sub


Private Sub Form_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKeyLeft:
ShpTestShooter.Move -350
Case vbKeyRight:
ShpTestShooter.Move 350
End Select
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft:
ShpTestShooter.Left = ShpTestShooter.Left - 350
Case vbKeyRight:
ShpTestShooter.Left = ShpTestShooter.Left + 350
End Select
End Sub

arrrrggggh!!
how did he managed to get his pacman working???
My program refused to respond to my pressed keys
which are arrow buttonws
Put a breakline, it absolutely refused to go there

Image Moving
How can you get a picture box or an image to move across the screen. I'm guessing you can use a timer, but am not quite sure how to set up the timer. What I have is... a for next loop in a sub called PlaneMove (I call that sub in GameLoop). So, in this sub, I set the image.visible = true, and then the for next loop is
For i = 1 to MAXPLANEX (MAXPLANEX is the end of the form to the right)
Picture.move i, Y (Y is an int(Rnd) formula to make the y coordinate a random number)
Image.move i, 0 (I don't know why, but I can't get the picture box to move across the screen without an image moving across the screen also, but if I just have an image it jitters, and has problems.)
Next i

So anyway, the result of the for next loop is that it works, the Picture Box of an image of a plane moves across the screen very smoothly, but there is one problem. The whole loop has to go through before any other action can be done, and in this case in this game, Player 1 is a tank that has to shoot the plane, and it should be able to move left and right, and up and down, with the max y coordinate set at an integer so that it can't pass that integer. The problem is, the plane has to move through the entire screen, and only after it passes, will the tank move to the cursor position, and Player 1 can't shoot at all, because as soon as the plane goes through the loop and gets to the end of the screen, and once the new tank picture is drawn at the tank coordinates, the planeloop starts again, and therefore there is no time for the ball to shoot out and move. I'm guessing that with a timer, the plane can move through the screen, and Player 1 can do all of the other actions without any problem, but I just can't figure out an algorythm for the timer, so I'm just basically stuck in an everlasting loop... both in the game and in the code... any suggestions?

Moving A Image
here is my code:

Private Sub Timer1_Timer()
imgshield.Move Left - 100, Top + 1000
End Sub

i've placed my code in the timer and form coding areas but it still won't work... why won't it... I want it to move constantly I.E.: like this simple little "."

I want it to go like this:
. . . . . . . .

I want it to be constantly moving until I tell it to stop

P.S. my interval's set at 1000

Moving Image
anyone have a code snipplet for that I could place in a timer to make an image move (right to left) accross my form? thanks in advance!

Moving Image (gif)
How can I add a moving gif on my form?
when I do it with a picture box or image it wont won't move.
can anyone tell me how I can do this?


//golles

Moving An Image
Is there a way where I can drag an image anywhere i want on a forum and when i let go the image will stay there?

Moving Image
I want to devolop

a project in which i want to gif images they are moving means animated
but when i put them on label or imge control
they become constant means not moving how can i use the please give some
sugestion
Thanks

Moving An Image
how do i make an image move?

Image Moving
I have an image control on a form, and I'm trying to get it to move.

I want the user to be able to either click/drag it to anywhere on the form, but can't get the right event/code combination. Anybody know how to move an image during run-time?

Thanx.

Moving An Image
hello all,

i m trying to drag an image from a specific place on the form,
and drop it on another .

how can i do that?

tnx
LirLir

Moving An Image Everywhere
can someone please help me i need to know how to move an image in all directions randomly such as right left up diagonally ect (RANDOMLY) please

Moving Image So It Goes Everywhere
i need it so when i press go ..
the image will move randomly everywhere

such as a bird.. so when i press go the bird will fly down up left right diagonally and it will do it randomly

PLEASE HELP ME

Moving Image Help
Hi everybody!
can anyone tell me agood way of making an image float randomly around the screen? i've tried 'do until ' and 'if then' without getting the results I want.
Thanks in advance for any suggestions.

Moving An Image
Thanks to the guy who helped me move the image around the screen by using the keys but i have another problem. How do i make it so that when the user presses the keyboards left arrow, the image moves left but changes to another image. e.g.

i want to move the elephant image left
when i press left i want to move the image but change the image to one that is of an elephant facing left

how do i do this with al the arrow keys?

Moving Image W/ Mouse
I wanted to have an image move according to the mouse cursor. I've managed to do that with a mousemove procedure on the form. However, the image moves fine on the right side of the screen, but the image doesn't move so smooth on the left side. I'm not sure why there would be a difference, and I cannot change the effect.

Moving Image- Flashes
Hi,

I've got a very simple program, where a image in VB moves around the screen. To get it to move smoothly, i've put a timer on at 1ms, and it moves 1 pixel every ms. It works great.
However, the image "flashes" as it moves- black lines appear down it- like watching a TV screen through a camera. I've tried changing it to 10ms, 10 pixels, etc, but that doesn't really help much, since it is jerky.

Moving Image Too Fast...
Im working on a game that sets a image's position every 500
milaseconds, it works fine just looks well.... dumb... it shows the image move over then down kinda like streaking it to its position, I think bitblit will fix this but id rather not get into all that if there is an easyer way and yes it is very inportent that it sets the position every 500 milaseconds

Image Loading/moving
I was wondering if there is a way to load or move an image from a different form.

For example, if I have a picture in Form2.frm and I want to be able to display that image in Form1.frm at different times during the program, what would I do? I want to do this so that I can just store all my pictures in a form separate from my game and just call the images whenever needed.

Any help is appreciated.
Thanks.

Moving An Image With The Mouse
hey all, just wondering if anyone could point me in the direction of moving an image by clicking on it, and while holding the mouse button down and moving it in any direction, how to change the properties of the image(in this case, the .left, or .top properties)
Thanks in advance.

Image Moving On Keypress
2 questions.. # 1, is there a KeyAscii for the arrow up down right left keys??


and #2, when i make Image1.left = image1.left - 25 , it moves but it flashes. Thats very annoying and ugly, ive tried transparent and not transparent, it always flashes. is there a way so it moves without flashing???

Making A Moving Image Go The Other Way?
Hey, Ive got an image moving around on my screen using option buttons, (up down left right) and I want, when it gets to a certain point, to go the other way. So say up is selected and it gets to y 3180 I want it to start going down. Ive had a go at the coding on the 5th line but it doesnt work, the other 4 do though. Can anyone help please? thanks

Private Sub Timer_Timer()

Dim original As Single


If OptDown.Value = True Then
ImgCross.Top = ImgCross.Top + 50
End If

If OptUp.Value = True Then
ImgCross.Top = ImgCross.Top - 50
End If

If OptLeft.Value = True Then
ImgCross.Left = ImgCross.Left - 50
End If

If OptRight.Value = True Then
ImgCross.Left = ImgCross.Left + 50
End If



If ImgCross.Top = 3180 Then
OptUp.Value = False
ImgCross.Top = ImgCross.Top - 50
End If

End Sub

Label In A Moving Image
is there any way to put a label or text inside a moving image so it contains some text in the center even when moving? This text will randomly changes everytime a certain event triggers

or I have to use the frame thing??

Moving An Image Up On Click
Im making a helicopter type game, and i want the helicopter to rise when i click the left button on the mouse. Also, i would like the helicopter to fall when the left button on the mouse isnt being clicked. My image name is helionclick. Im using vb 6.

Moving Image On Vb Form
hi all,

i want to add a image on vb form but not a static image .image like..
example: when we copy a folder and then paste somewhere moving
image of copying process.
anybody can help me.

thanks ,
abhishek mishra

Moving The The Form With Image??
i dont undersatnd realy how to do it

i took off the border (purpusly) i cant spell


Code:
Private Sub imgtop_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
frmmain.Top = Y
frmmain.Left = X
End If
End Sub


this is what i did, it moves but its so glitchy its jumps all over

plz help

Getting A Moving Image To Reverse Itself
Hey, you guys were really helpful last time, but alas I'm stuck again. I've got an image (ImgCross) moving around a screen with check boxes, but I want it, when it gets to a certain coordinate to go the other way. Any ideas? Thanks

The first four lines work fine but the bottom line doesn't do anything

If OptDown.Value = True Then
ImgCross.Top = ImgCross.Top + 50
End If

If OptUp.Value = True Then
ImgCross.Top = ImgCross.Top - 50
End If

If OptLeft.Value = True Then
ImgCross.Left = ImgCross.Left - 50
End If

If OptRight.Value = True Then
ImgCross.Left = ImgCross.Left + 50
End If



If ImgCross.Top = 1800 Then
OptUp.Value = False
ImgCross.Top = ImgCross.Top - 50
End If

Moving And Image W/ The Mouse.
Hi, I am working on a simple board game. When the player moves a piece, an image box appears (that moves with the mouse), the picturebox containting the board is redrawn wihout that piece, and it is moved to the new spot and the "dummy" piece dissapears and the board is redraw again with the new move. My only problem is: the pieces are round, and the image box that moves is square. When you move the piece, you can see the square border. What can I do about this?

Moving An Image With The Mouse.
Hi. I am creating a Vscroll OCX and i have everything finished excpet for moving the slider bar with the mouse when it is clicked on. Currently i am using GetCursorPos to try and move it.. Which it does move but depending on where the form ison the screen it moves differently.


What is the best way togo about something like this?

THe code i have so far is

VB Code:
Public Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINT_TYPE) As Long Type POINT_TYPE  X As Long  Y As LongEnd Type Private Sub imgSLIDER_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 ThenGetCursorPos COORD    imgSLIDER.Top = COORD.Y * Screen.TwipsPerPixelY - 2200   End If End Sub



The -2200is just and arbitrary number. IT has no meaning. i'm just trying to figure this out.


I have attached a pic of the control to give you an idea of what it looks like.

Thanks alot for any help!

Moving/Draggin Image Box???
hey all,

How do you drag/move and image box on a form??

thanks
b

Moving An Image In All Directions
i was wondering how to make a image move around in all directions such as it moves right, then left, then up, then top right diagonally, then down ect
also how to randomise it

Help!! Moving An Image On The Screen
I am wanting to do it so when someone clicks on and image they can move it any where on the screen,and when they release the button the picture stays in that location...

Moving An Image In A Picture Box
Hi,

I'm writing a basic mapping type application in vb6. Within a picture box control I use simple drawing commands to create lines, circles,points etc. I have a toolbar with buttons to pan, zoom, scroll the display etc.

I now wish to enhance the viewing functions by introducing a 'hand' where the user clicks anywhere in the picture box, and drags the complete current image in any direction. On the MouseUp event the plot is redrawn at the new location.

Whats the best way to smoothly move the image? I understand that I'd have to capture a bitmap of the current view, and move this around keeping track of the screen coordinates and preserving my white background screen, but have no idea how to do this. I'm told this involves "blitting".

Any ideas?

Thanks...

Controlling A Moving Image Box - HOW??
Greetings all..........
thsi is probably sooooooooo simple that i will feel like a goose when the answer arrives.

situation. I am a basic to intermediate user of VB. Am teaching students at the moment the principals of conditional looping and using timer controls.

interface: have a single image box that we get moving by using

imgcar.left =imgcar.left+50

with every tick / interval of a timer control.

Students (and myself want to know and understand HOW we can stop the image when its right edge touchs the right sid eof the form.
We all thought that this would work fine

if form1.left=imgcar.left then
timer1.enabled=false
end if

.but it doesnt!!!!! Image just keeps speeding off into infinity.

We dont get it!!!! Do we have to break in to the existing process or something??????

they really want to get in to creating simple pacman type games interface but realy need to understand how to make these images stop moving in a direction and change to a different direction.


Has anyone got a solution for us.

Thanks

Moving Image Box In Certain Direction?
Hi,

Is it possible to move an image box by a certain angle, e.g. '180' to move the image down, '270' to move it to the left, etc.

Mark

Moving Image With Keyboard
how do you move an image around a form using the keyboard buttons????

Moving And Renaming Image Files
How would I take an image file from the cd that my program runs on then rename it and move it to a directory on the hard drive?

Disable Moving Of Image In Listview???
I use ListView in Microsoft Windows Common Controls 6.0 (SP6). I can add image to fill background but when i scroll-down, the image is moved!

I want image not to move. How i have to do?

pls help!

Thanks

Moving Image Inside PictureBox
I want to move a image loaded in the picture on mouse movement. Like it happens in acrobat reader. I am trying to do it with a single picturebox. Have searched the forum completely for this buyt couldnt find the method which would let me move the image with out using two picture boxes ie... without using one picture box inside another one ....

thanks in advance..

Pls check ...

Moving A Single Image From One Form To Another
Hi,

i wonder if anybody can help me.

My Problem is as follows:
I have two forms. The first form is full screen size and the second form fills half of the screen at the top. On the second form i have an Image, the first form is blank. i want to move the image by clicking on it with the mouse and moving/drag it on to the first form is this possible? im not sure it is.

Another way would be to have identical Images on both forms but have the Image on the first form hidden. So when i drag the image from the second form to the edge it will become hidden and at the same time the image on the first form will appear still stuck to the end of the mouse giving the impression of ther only being one image. Would this work and if so what would the code be? Or is ther an easier way of doing it?


Thank for your help!

Moving An Image In The PictureBox (RESOLVED)
Hi there,

I'm trying to make a button that enables to move an image in a picture box.
For example when I click and drag the mouse to left the program makes the picture in the picture box move "a bit" (to be defined) left...

Is it possible? Any input is apreciated!

Thanks in advance

Moving An Image... With The Push Of A Button!
That's exactly my problem... I can't really seem to to it.

Basically, I'm making a bog-standard game which is based on top-down view mazes. The player has to guide the character through said maze, and I'm wanting to get the up, down, left and right buttons to move the character. Simple enough, but I can't get it to work...

I've got this here code, which I was sure would work:


Code:

Private Sub Pic1_KeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer)
Select Case KeyCode
Case 37 'Left arrow
If Not Pic1.Left < 50 Then 'Check whether the picbox can be moved 50 to the left
Pic1.Left = Pic1.Left - 50 'Move the picbox 50 to the left
End If
Case 38 ' Up arrow
If Not Pic1.Top < 50 Then 'Check if the picbox can be moved up 50
Pic1.Top = Pic1.Top - 50 'Move the picbox 50 to the top
End If
Case 39 'Right arrow
If Not Pic1.Left > Me.Width - 50 Then 'Check whether the picbox can be moved 50 to the right
Pic1.Left = Pic1.Left + 50 ' Move the picbox 50 to the right
End If
Case 40 'Down arrow
If Not Pic1.Top > Me.Height - 50 Then 'check if the picbox can be moved down 50
Pic1.Top = Pic1.Top + 50 'Move the picbox down 50
End If
End Select



It compiles fine, but the image doesn't want to move when I press the appropriate key.

Can anyone help me?

Smoothly Moving The Image Control
I have an image viewer in my project. The image viewer consists of a form, an Image control inside the form named imgView. And there is also a slidebar, which controls zooming in on the image. Anyways, what I need to do is allow the user to be able to move the picture around if it gets too big to be completely seen in the form, like in ACDSee. I've got most of it done, but it's not smooth like I want it to be.

See, I want the image to move dynamically while the user is dragging it around to the new position. I've got that working with the MouseMove event and then Move function of the Image control. Here is the code I have written so far.

Code:
Private Sub imgView_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    imgView.MousePointer = 5 'change the cursor to resize cursor
    MDX = X
    MDY = Y
End Sub

Private Sub imgView_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'Moves only if MouseDown is active. Checks by checking the MousePointer icon.
    
    'The following conditions ensure that the image doesn't get moved too far off
    'the screen.
    If imgView.MousePointer = 5 Then
        If imgView.Width > Me.Width Then
            If (imgView.Left + X - MDX) > 0 Then
                imgView.Move 0
            ElseIf (imgView.Left + X - MDX) < (Me.Width - imgView.Width) Then
                imgView.Move Me.Width - imgView.Width
            Else
                imgView.Move imgView.Left + (X - MDX)
            End If
        End If
    
        If imgView.Height > Me.Height - 530 Then 'the 530 accounts for the topbar with the min/max/close buttons
            If (imgView.Top + Y - MDY) > 0 Then
                imgView.Move imgView.Left, 0
            ElseIf (imgView.Top + Y - MDY) < (Me.Height - 530 - imgView.Height) Then
                imgView.Move imgView.Left, (Me.Height - 530 - imgView.Height)
            Else
                imgView.Move imgView.Left, imgView.Top + (Y - MDY)
            End If
        End If
    End If
End Sub


This code also prevents the image from being moved too far off the form. THE PROBLEM: when I zoom in on an image, and THEN try to move it, the Image control blinks while I am dragging it. I don't want it to blink.. And also, if you look at my code, it moves the Image horizontally first, and then vertically. I know the MOVE function is able to move horizontally and vertically simultaneously, but I need to check to make sure the image isn't being moved too far off the form. Hopefully you will understand what I am talking about if you study my code carefully. When I am moving an image of large size, even if I don't zoom in on it first, you can see the image first moving horizontally and then vertically. Basically, it's not very smooth.

Any suggestions? Thank you in advance.

Moving An Image Control Without Flicker ?
Hi,

Is it possible to move an Image control without flicker ? I
couldn't find any AutoRedraw property for Image controls.
Actually I was wanting to move the image in a scrolling manner.
But with the code I have built, there are flicker lines on the
image when the code is run. The dimensions of the .JPG are approx.
150x600 pixels. I am posting parts of my code below.
Hope you can help me remove those flickers.

Why I don't use a Picture box instead ? I have to show a few
lines _over_ the moving image, and I don't know if Picture boxes
can be made transparent. Nor could I "Send To Back" the picture
box.

Regards

Code:
Private Sub MyDisplay()

    Dim Start As Integer
    
    Start = Me.Width
    
    Me.Show
    
    Do While Not blnExit

        Image1.Left = Start
        
        If Start = 0 - Image1.Width Then
            Start = Me.Width
            Form1.Cls
        Else
            Start = Start - 10
        End If
        
        MyPause (10)
        
    Loop

End Sub

Private Sub Form_Unload(Cancel As Integer)
    
    blnExit = True
    
End Sub



And the Module code is given below,

Code:
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long

Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Public Sub MyPause(Optional ms As Long = 3000)

    On Error Resume Next
    Dim tc As Long
    tc = GetTickCount
    While GetTickCount < tc + ms: Sleep 1: DoEvents: Wend
    
End Sub

Moving An Image 1 Pixel Down And To The Left...quickly!
What would be the FASTEST way to move a picture for a screensaver down and to the left? is there an offset picture API?

Moving An Image With The Up, Down, Left, And Right Buttons On The Keyboard
can someone show me some smaple code that deals with moving an image with the up, down, left, and right buttons on the keyboard?

Copyright © 2005-08 www.BigResource.com, All rights reserved