473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Quick & Smooth Scrolling in a Graphics item?

I've narrowed down my problem, but I've yet to find a
solution, so here goes again:

Private Sub Form_Main_KeyDown([usual arguments]) Handles
MyBase.KeyDown
Dim PaintEventArgument As New PaintEventArgs
(CreateGraphics, Nothing)
If e.KeyCode = System.Windows.Forms.Keys.Left Then
For XOffSet = 1 To 40 Step 1 ' Simulate scrolling.
InvokePaint(Me, PaintEventArgument)
Next
XOffSet = 0 ' Scrolling finished.
If CurrentCoords.East > 0 Then ' Reflect new player
position.
CurrentCoords.East = CurrentCoords.East - 1
Else
CurrentCoords.East = Cell.GetUpperBound(0)
End If
ElseIf [Code for other keycodes]
Else
Return ' Exit if key was not recognized.
End If
AssembleMap() ' Uses new CurrentCoords to assemble a new
map.
InvokePaint(Me, PaintEventArgument) ' Displays new map
w/ 0 Offset
End Sub
Private Sub Form_Main_Paint([usual arguments]) Handles
MyBase.Paint
e.Graphics.DrawImageUnscaled(MapInMemoryBitmap, _
XOffSet - 40, _
YOffSet - 40)
End Sub

The problem is slow execution (1.6 seconds, measured
internally) of the 40 DrawImages I call with successively
larger offsets to simulate scrolling upon keydown. The issue
does not appear to be the invocation of the paint event in
doing so, as outsourcing the code to another procedure
(ScrollMap w/ CreateGraphics.DrawImage) showed no
performance increase relative to using the more convenient
InvokePaint.

I've tried using different DrawImage schemes, such as
defining src and dest rectangles, with no appreciable
performance increase.

Repeated transformtranslations might be just what I'm
looking for, but I can't seem to get them to work.

If anybody has any answers or knows a place where I might
find some, I'd be immensely grateful.

The Confessor.
Mar 8 '06 #1
0 991

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James CC | last post by:
I have a strange bug in C# using windows forms. To make sure it's not some bug with my code, I've gone back to a simple test app, and still see the same behavior. I have created a simple C#...
8
by: Brian Henry | last post by:
I created a smooth progress bar with this code.. but if you update the values in a row quickly of it and watch it on screen it flickers... how would i change this to reduce the flickering?...
0
by: salad | last post by:
I took the Bart down to San Francisco and joined a couple thousand other nerds to watch the Vista/Office launch. The receptionist was quite pleasant and getting the event packets a smooth...
1
by: Bishman | last post by:
Hi, I have been trying to get text to scroll smoothly accross a windows form using GDI+ and a timer. Changing the position of the text by a configurable amount and calling invalidate to force a...
0
by: LostInMd | last post by:
Hi All, I've got an owner drawn listBox where I draw and measure the items that I add to the listBox. For example, I have a listBox that can only display 10 characters on each horizontal line. ...
1
by: tromton | last post by:
heello, i havee one div element in my site with several anchors, that i link to. to change from anchor to another id like to have a smooth scrolling effect. all the smooth scrolling effects i...
1
by: PankajGaur | last post by:
Hi, I need to create a Ellipse shaped user control which have folloiwng attributes: 1) The edges are smooth 2) The control shuld only be selected when click on the ellipse shape & not when...
0
by: =?Utf-8?B?UGFua2FqR2F1cg==?= | last post by:
Hi, I need to create a Ellipse shaped user control which have folloiwng attributes: 1) The edges are smooth 2) The control shuld only be selected when click on the ellipse shape & not when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.