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




Simple Moving Of A Picturebox Without Flickering


Here is what i want:

i have a form and a picturebox when the users holds down the mouse on the picturebox the picturebox must move allong with the mouse without flickering, so this is what i have:


Code:
Dim OrX As Single 'original x
Dim OrY As Single 'original y
Dim MsD As Boolean 'check wether mousebutton is pressed

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsD = True
OrX = X
OrY = Y
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MsD = True Then
Picture1.Left = Picture1.Left + (X - OrX)
Picture1.Top = Picture1.Top + (Y - OrY)
OrX = X
OrY = Y
Refresh
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsD = False
End Sub


i can move it now (well a little bit anyway) but it flickers like hell,
PS: picture1.move flickers just as much




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Flickering While Moving Picture Box
There must be a solution....

How Do I Stop Flickering In Moving Graphics?
I haven't dealt with graphics in vb before, but I know of a common graphics method to reduce/eliminate flicker in animations called double-buffering.

The flicker is caused from clearing the old frame before drawing the new one. To counter this problem you actually would have 2 picture boxes (or whatever you're using) the first one is the visible one that will display the animation. On the second buffer, you do the calculations for the next frame and place all the objects there, then once the frame is ready for display you change the image on the visible buffer to that of the second buffer.

Since I haven't done this in vb before I'm not to helpful in the code department, but hopefully you'll find this method usefull.

PictureBox Flickering!
flickering happens whenever a picturebox is cleared and it's contents redrawn. I am facing it with the application I've attached, just click the 'Graph' button and try to modify the scale!

it is really annoying, does anybody know how to fix it?

Picturebox Flickering
Hi,

Is there anyway of stopping the text from flickering in the attached program? I need extra smooth text whatever the speed it is travelling.

Regards.

PictureBox Flickering Problem!
Hi all,
i using picturebox to marquee a text, so the text will continuously scrolling form bottom to top...my PROBLEM is how to put off the flickering?? that flickering getting worse after i fill in a lot of text..

Code:
Private Sub Timer1_Timer()
Const MyStr = "Hello, this is a test string"

Static TopText As Integer
Static TopLoaded As Boolean

Dim Speed As Integer
Dim NotShowing As Long


Speed = Screen.TwipsPerPixelY

If Not TopLoaded Then
 
    TopText = Picture1.ScaleHeight
    TopLoaded = True
End If


Picture1.Cls


Picture1.CurrentY = TopText
Picture1.CurrentX = (Picture1.ScaleWidth 2) - (Picture1.TextWidth(MyStr) 2)

Picture1.Print MyStr

NotShowing = (TopText + Picture1.TextHeight(MyStr))
If NotShowing < 0 Then
    TopText = Picture1.ScaleHeight
Else
    TopText = TopText - Speed
End If
End Sub

Flickering Label And PictureBox
I am writing an application that gets GPS information once a second and displays the current speed in a label's caption, and the current speed limit as a .bmp in a picturebox. When I run the program, the speed label sometimes flickers as though the PPC doesn't have the time to repaint it correctly. The same behaviour occurs in the pictureBox when I blink the sign using alternatively visible=true and visible=false.

The problem persisted when I tried to hide the label before updating the caption, and then showed it again. I also tried using different backgrounds and transparancy settings.

I am using PPC2002 and eVB 3.0.
The label is 65 pixels high and 110 wide, uses Arial font at size 42
The pictureBox is 102 by 102 pixels

Any suggestions is appreciated.

Thank you
- Niklas Ringdahl

Solution To Non Flickering Resizing/moving Of All Types Of Controls
Hi.
Some time ago i posted a question about the following subject:
"how can i make a control appear to slide in the screen without seeing it flickering like hell or making it look stupid"

well, not needed to slide in, but just an animation would be fine.

I bumped the subject a couple of times but no reaction at all. After a lot of trying i found a solution that worked quite well. Any reactions?

Hope it works fine,

Greets, Dee.


In this example i explain how to resize a form, and make it look like it is
animated. It starts to change dimensions fast and then slowing down after some time. The slow down effect i achieved by implementing a simple powerfunction.
---------------
set timer at interval=1 en standard enabled=false



Code:
dim newformwidth as double

Public Sub TMRAnimatie_Timer()
me.Width = newformwidth
End Sub




Code:
Public Function CollapseSideScreen()
Dim widthnow As Double
Dim widthfinal As Double
Dim widthdiff As Double
Dim actiontime As Double
Dim starttime As Double
Dim endtime As Double
Dim passedtime As Double

widthnow = me.Width
widthfinal = 1000 'insert wished width value here
actiontime = 1.2 'seconds , can be replaced
starttime = Timer
endtime = starttime + actiontime
widthdiff = widthfinal - widthnow

animationchange = False
TMRAnimatie.Enabled = True
While Timer < endtime
DoEvents
passedtime = Timer - starttime
newformwidth = widthnow + widthdiff * (1 - Exp(-passedtime / (actiontime / 10)))
Wend

TMRAnimatie.Enabled = False 'stop timer
TMRAnimatie_Timer 'call timer one last time or you might miss last change made within while statement
End Function


Some extra explanation:
newformwidth = widthnow + widthdiff * (1 - Exp(-passedtime / (actiontime / 10)))
sets the width at the previous width + the difference old-new times a factor 0-1

the function 0-1 is basically:
(1-e^(-t/C)) with in this case C = actiontime/10 because it makes sure that 99% of the change is done in around 80% of the time
Try plotting the fuction with t variable and a certain C, you will see that the function rises quickly to 1, and then slowly dims out till it reaches one eventually.

...........

Why not do it with just a timer?
This makes it impossible to control the actual speed for different controls to change/resize. This because timers are very inaccurate

Why not do it within the while - wend function?
Because of the doevents in the function you will see that the resizing will go extremely weird. You will also notice the screen will flicker. This is, i think, because there are too many changes. The screen simply cant refresh the UI fast enough.

Leaving the doevents solves the problem. A very accurate resizing can be seen. However... You cannot do anything else at that moment till the progress is done.

I hope this was somehow valuable

Remove Flickering When Moving Some Object In Form Using Timer
is there any way to remove flickering when moving some object in form using timer

Moving Picturebox
ok, here's my question :

I put one picturebox on the left of my form on the foreground and one picturebox on the
right of my form on the background. You can select the left picturebox by clicking on it, if you then click on the
right pictebox (on the background) the left one will be moved on top of the right one.

Can somebody please tell me how I can do this I've been searching for days... :'(

Problem Moving Picturebox
I created a simple card game (Solitaire) some time ago and I'm having a few problems animating. I used a picturebox to display each card and make a procedure for moving them around instead of just flashing them from one point to another. The odd part is that on my Win98SE computer the animation always works fine and is very smooth, while in my WinXP system, sometimes the program kind of freezes and them come back to life with the cards already on their final positions. It doesn't happen when I animate a single card, but when a lot of the cards go from one point to another. Hope someone could help.

Moving Aroung In A Picturebox?
i have a picturebox where i will be loading pictures too big to fit in it... i have set up h and v scroll bars but am not sure how to use them to move throught the picture

no i dont want to use an imagebox's stretch property

PictureBox Moving/Resizing
In my program, I'd like to implement like following.

At first, there is a picture.
Once I click picture box, the line wrap the picturebox appears.
If I drag and move and then drop, picture box is moved to there.
If mouse pointer goes go the line wrap the picturebox, arrow is appear and should resize that picturebox.

We can see that ,for example, in case we insert textbox into MS word.
we can move and resize, I'd like to implement right that.
How can I do it?
Could anybody let me know it?

Moving Text Around On A PictureBox Object?
I am wanting to move text from one position in a "PictureBox" to another by seemingly clicking and dragging and having the text appear to be moving along with the mouse pointer.

The text is introduced by the "PictureBox.Print" method. I have tried using the "vbInvert" with the "PictureBox" "DrawMethod" as you would do with lines and circles on the mouse move event, but this doesn't seem to work with fonts as I get a trail of text all over the screen!

At the moment I have worked around this by using a rectangle that represents the boundary of the text in question which is functional but I would like to advance this is possible.

Does anyone have a solution for this?

Thanks in advance, CrazySchmidt.

Moving A Ball In A Picturebox Using BitBlt - Please Help.
I have been trying to get a ball moving around a picturebox using BitBlt. I would like the to make the ball move in a do loop, which is located in the form load event. Can someone please help me out? I've tried moving the X and Y coords of the ball, but it didn't seem to work, but then again I might've done something wrong.

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 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 A Picture Inside A Picturebox
Hi,

I am trying to set the position of a picture inside a picturebox with the
folowing code:

pctOutput.Picture = LoadPicture(App.Path & "picture.bmp", [Size],
[ColorDepth], [X], [Y])

I didn't know what to fill in at [Size] and [ColorDepth] so the result was:

pctOutput.Picture = LoadPicture(App.Path & "picture.bmp", (315) - (315),
1, x2, y2)
'(x2 and y2 are declared variables)

My problem is that the picture hasn't moved at all, it's still in the upper
left corner :(
Does anyone here know how to set the position of a picture inside a
picturebox?

Thanks for your help.

Chris

Changing Background Brings On Flickering [RESOLVED=&gt; Bye Bye Flickering]
I've read much in this forum about flickering but as yet haven't found a solution to my specific case.
I use a image control which contains a gif image with transparent background. It stays in a fixed position on a picturebox, and in this picturebox the movement of a complicated geometric structure is simulated by repeated use of the line method inside 2 loops. Between any two consecutive static images I issue a Picturebox.Cls and this is the cause of much flicker, though the intended movement in the picturebox goes smooth like a dream.

Before I try to make my algorithm a little more clever I'd like to know if flickering can be held back by some other means.

Moving Objects/controls Inside A Picturebox!?!
I need to move several (LOADS OF) objects (labels/textboxes/etc) inside a picturebox quickly and easily....... is there anyway of doing this without deleting the objects and re-creating them inside the picturebox?

...and I need them actually inside the picturebox, not just hovering on top as if it looks like they're inside it!

Any help would be great!

Thanks in advance!

Simple: Moving Pic With Arrow Keys
How do I move a picture box with the arrow keys?

BMP On A PictureBox - Simple
Hi All !
How can I load a BMP (c:a.jpg) on Picture1.
I´ve tried all kinds of methods and nothing....
If it´s not much to ask I would also like to resize it to fit mi picturebox (I guess thats the easy part right?)

Thanks !!!

Simple Picturebox
umm hey. i just want to know how to change a picturebox's picture. heh yea it's a newbie's question. i'm just a kid in highschool doing a history project. lol

Moving Simple Application From Client Server
Well i have developed general ledger(Accounting application)in vb6 .now i have to refine it i want that suppose there are 6 computers.

so i want is database will be located only on one computer which is known as server and other 5 computer will act like client only front are end are installed on them the problem is that what modification i have to doneto make client server architecture
i m using access but ofcourse i will moved towards to sel server

Simple! Moving A Listbox Item For One Lsitbox To Another.
How can I move an item from

lstbox 1 ---> lstbox 2

I want the item to be removed from lstbox 1 and added to lstbox 2

Thanks for anyone who helps.

Moving From Simple Application Into Client Server
Well i have developed general ledger(Accounting application)in vb6 .now i have to refine it i want that suppose there are 6 computers.

so i want is database will be located only on one computer which is known as server and other 5 computer will act like client only front are end are installed on them the problem is that what modification i have to done

Simple Question About PictureBox
Is there a way an image can fit to the size of the picture box? Just like Image?

Thanks!

Simple PictureBox Question
hi,

I am drawing onto a picture box to craete a simple level editor program, how could i change the colour of the lines?

Many Thanks
Mathy

Very Simple PictureBox Auto Scrolling..Need Your Help
Hi..I have wrote a very simple code to scroll a picutebox automatically and on continues basis (file is attached).. I need your help in two things
1. make the scrolling from right to left
2. I want to make the pictue comes again after the first scroll ends.

Thanks

Simple!. How To SAVE A Picture From A PictureBox?
sups all
Can some1 plz tell me how to use the SavePicture to save a picture from a picturebox? (plz check ur code, iv got 2 incorrect codes allready)
tnx

Simple: Moving An Image To A Desired Place, But With An Animation Effect
Hello,

I am developing a Snakes and Ladders game, and when someone rolls the dice, this returns a value, and then this value is translated into a value of which the counter on the board must move to. I have managed to make a counter move straight to the target, but I wished for an animated effect where the counter moves across the board at a reasonable speed to the target. I presume a timer would be used for this effect? I am just not sure how I would go about implementing this.

Thankyou in advance
Nick

Edit:

So far I have constructed this code, but what happens is, I set the interval to say 10000, so it waits 10000 milliseconds and then exceutes within the space of one second, which is too quick to really see it moving slowly, how do I slow it down even more? So that it is a smooth move over about 4 seconds or so?

Private Sub Timer1_Timer()
While Image2.Left < 9240
Image2.Left = Image2.Left + 1
Wend
End Sub

I assumed that if I set the interval to 10000 it would run this routine every 10000 milliseconds until the Image2.Left = 9240?

How-to: Drawing With Picturebox (simple && Sample Code ;) )
edited

mistake in this file. get the next one, please

--------
www.tac822.net - tablatures i acords per guitarra en català
www.tac822.net - tabs and guitar chords in Catalan.

- Catalonia IS a nation -

Edited by - johnminkjan on 11/23/2005 10:57:11 AM

Code For Moving To The First Blank Cell In A Worksheet; Moving Left,right,up Or Down
I have created an application form as a userform in Excel. I need to send the data entered into my text boxes when the program runs to separate excel cells in a worksheet.

My problem is I can use code that will send the textbox entry to a specific cell eg. If my textbox is named Surname I can say

range("a5").value = surname but if I do that when I run the programme to enter the next record for someone else the first record will be overwritten.

I NEED A CODE LINE THAT WILL TAKE ME TO THE FIRST EMPTY CELL AND ALLOW ME TO MOVE DOWN OR TO THE LEFT OR TO THE RIGHT

Clicking On A PictureBox -- Returning Coordinates Of Click Inside Picturebox?
Alright, I have a picture box on my form. Essentially what I'd like to do, is when a user clicks anywhere inside the picturebox (Private Sub piece_Click(Index As Integer)), I'd like it to return the current position inside the picturebox. (For example, the top left would be 0,0).

Is this possible? Thanks.

Click Event On PictureBox Control Does Not Work When AVI Is Opened In PictureBox
Hi,

I want to utilize click event on PictureBox Control. The name of the PictureBox in my code is Display1. The following is the function triggered by Click Event.

Private Sub Display1_Click()
MsgBox "Reached Here"
End Sub

This works fine. But when I open a avi in this PictureBox using mcisendstring, the function is not reached on clicking the PictureBox. What is the reason.

Thanks in advance.

Moving Balls To Moving Images??
Please take a look at this as it is related to my question
Thread

is it possible for the create images to be an image type that is already drawn?

Pass PictureBox To A Function To Return Modified PictureBox
I can't find a solution to my problem.

Trying to use a function. I want to pass a PictureBox control to this function. I want this funciton to modify the PictureBox's graphics (Lines, Boxes, Circles, etc.) and then to return the PictureBox back to the form with it's new graphics.

This is what I thought should work. Any help, or solutions?


VB Code:
Option Explicit Function Update_Graphics(PicBox As Object) As Object    'Also have tried.. As PictureBox    PicBox.Cls                                          'This does not draw    PicBox.Scale (0, 0)-(50, 50)    PicBox.Line (0, 0)-(50, 50)        Set Update_Graphics = PicBoxEnd Function Private Sub Command1_Click()    Dim objGraphics As PictureBox    Set objGraphics = Picture1    Set Picture1 = Update_Graphics(objGraphics)  '    Picture1.Cls                    ' This draws fine'    Picture1.Scale (0, 0)-(50, 50)'    Picture1.Line (0, 0)-(50, 50)End Sub


Thanks!

Flickering
Im working on a teleprompter program for my video production class and ive got the text scrolling with a label. the only problem is when the label scrolls, i get that classic flickering usually associated with timers. i tried slowing down the timer, and speeding up the movement of the label, but now it just flickers a little slower, and its all choppy. is there a way to get rid of that flickering?
-thanks

End The Flickering!!!
OK so I am definatly a newbie to VB6, and here I am trying to write with it (first program in vb6 ever), and I am having some massive flickering problems . Can you recomend how I might fix that, right now my program moves the "shapes" by changing the tops and lefts of the shapes. What can I do?

Flickering...
If i were to have a timer moving some images and the interval is at 1 how can I get rid of that ugly flickering? While the images are moving across the screen they will flicker white every so often, and I was wondering if there is some way of stopping that. Thank you.

Flickering In Vb
hi just started making my first game where u can roam around and interact with the environment but there is a problem. I am using 4 timers for movement that correspond to the keys w,s,a,d but when i run it and walk around the character flickers. I was just wondering if any one knows a quick way to eliminate this undesireable effect.

Thanks

Flickering
I've searched this forum, but haven't figured out my problem.

I have image controls on my form, and when I move them, they flicker. I want no flicker.

I've read on other posts about possibly using GDI+, but I don't know what it is. Googling for it makes it seem like its a VB.net thing and not VB 6.0. Is this right? Or could GDI+ be the solution to my problem? If so, is there a link that explains to me how to use it. If I could just build a Hello World application, I can probably learn it fast enough to use.

Also, as I move the objects around on the screen, I like to give the user the option of having it trace a path where it's been. I do this with pset statements. But the problem is that the trails disappear if another form is moved over the paths. The few things I've tried, like autoredraw or using line objects also cause major flickering. Could GDI+ solve this for me too?

Thanks for your thoughts.

Flickering
i am using a loop with a wait function in it to move objects across the screen, how do i stop the flickering when doing this?

FLickering ?
Hi,

When i put label on frame, sometime label flickering even i'm not update/change anything on the label. Flicker happen Especially when i move mouse. Is that normal?

Flickering
I have a few games with bouncing labels. but the labels flicker. I don't want this so how do I prevent this?

Dam Flickering
Hi,

I have many child forms (MDI Form also) with many, many textboxes on it. When i run the save procedure, each form opens up, data is saved, then form closed, the next form is then loaded and so om.

The problem is that the rate of loading / unloading is uick and the screen flickers as a result.

I have tried to use the "hide" and "visible=False" in the code to no avail.

Is there a way to hide the program as it saves the data, then show it again when the save process has completed ????

The Flickering...
I can't beat damn flickering on my form. I'm still not 100% what is actually causing it... I think it might be the PlayNextSong Function.

Maybe I should just change the form style?

Don't steal code out of my project please.

Flickering
How do I eliminate the flickering on controls like windows media player, picture control, image control, etc.

Flickering...ng...ng...ng - Need Help
hello to all

i attach something i am trying to write, but it flickers.
please help me with this.

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