473,387 Members | 1,721 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,387 software developers and data experts.

API Or DirectX In VB.NET

Ok, i have a program where I need to animate images on a background.
However, the VB.NET CreateGraphics is not fast enough to do it without
flicker. I am not a very advanced programmer, and cannot figure out
how to use DX or API in VB.NET. Could someone give me some simple but
specific code that draws an image to the screen? Thanks.
Nov 21 '05 #1
4 1255
Though I have not used, you might want to check this one:
http://www.codeproject.com/cs/media/...reeDrawing.asp

"Anagnos" <fr***********@yahoo.com> wrote in message
news:57**************************@posting.google.c om...
Ok, i have a program where I need to animate images on a background.
However, the VB.NET CreateGraphics is not fast enough to do it without
flicker. I am not a very advanced programmer, and cannot figure out
how to use DX or API in VB.NET. Could someone give me some simple but
specific code that draws an image to the screen? Thanks.
Nov 21 '05 #2


Thanks. Sadly, the code on that site is in C.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3

"Anagnos" <fr***********@yahoo.com> wrote in message news:57**************************@posting.google.c om...
Ok, i have a program where I need to animate images on a background.
However, the VB.NET CreateGraphics is not fast enough to do it without
flicker. I am not a very advanced programmer, and cannot figure out
how to use DX or API in VB.NET. Could someone give me some simple but
specific code that draws an image to the screen? Thanks.


How about something like this?

LFS

Private bar1 As Pen = New Pen(Color.Blue, 12)
Private bar2 As Pen = New Pen(Color.Red, 12)

Private buf As Bitmap
Private bufG As Graphics
Private center As Point
Private tip As Point
Private grx As Graphics
Private ang As Single

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
buf = New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height, Me.CreateGraphics)
bufG = Graphics.FromImage(buf)
center.X = Me.ClientSize.Width \ 2
center.Y = Me.ClientSize.Height \ 2
Timer1.Interval = 20
Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If grx Is Nothing Then grx = Me.CreateGraphics
ang += 0.05!
If ang >= (2 * Math.PI) Then ang = 0
tip.X = CInt(Math.Sin(ang) * center.X * 0.6)
tip.Y = CInt(Math.Cos(ang) * center.Y * 0.6)
bufG.Clear(Color.White)
bufG.DrawLine(bar1, center.X, center.Y, center.X + tip.X, center.Y + tip.Y)
bufG.DrawEllipse(bar2, center.X - ang * 20, center.Y - ang * 20, ang * 40, ang * 40)
grx.DrawImageUnscaled(buf, 0, 0)
End Sub
Nov 21 '05 #4
Thanks, that worked out great!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #5

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

Similar topics

7
by: kastillo | last post by:
Im trying to install directx 9.0 c , but i simply cant . When i run the installer it just says " The installed components are ready to use". This is the report on directx.log : 09/10/05...
2
by: Akkadian123 | last post by:
Hi guys, I'm a student of c#, and I was wondering how one would take advantage of multimedia in most c# apps/games. I assume one would use directx9, since there doesn't seem to be any support...
2
by: Michael Mayer | last post by:
First of all, sorry for the cross-post. Seems like there should be a managed directx newsgroup. I'm trying to open the following sample application that comes with the DirectX SDK....
6
by: ammd | last post by:
Hi, I installed Microsoft DirectX 9.0 SDK (Summer 2004) but when I create a project and try to add the necessary references I can't find them. Does anybody know where to look for them? BTW, I have VS...
2
by: Diego_Atos | last post by:
I want to create objects using directX. I downloaded SDK version of DirectX. I've installed it. Which is the right dll to add to references? I can't find it. thanks -- -Diego (Atos)-
4
by: Junaid Hussain | last post by:
Hi, I am thinking about developing a 3D pool game in C# using DirectX, however when I compile a C# at the command prompt using; csc PoolGame.cs , I get the following error message; The type or...
9
by: Mike P | last post by:
Problems, problems... Im trying to create DirectX Projects within C# and to also look at the latest DirectX C# Samples. I have just installed MS Visual C# .net Standard Edition on my Windows...
0
by: Harvey Cohen | last post by:
Hello all, I have some C# code that implements calls to DirectX.DirectSound. It compiles under both VS .NET 2003 and VS 2005 and runs under VS .NET 2003 and VS 2005 on a Compaq laptop (Windows...
14
by: Jessica Weiner | last post by:
I am writing an application in C# which need to plot graphs and simple shapes (polygons, circles, squares etc). Which library is better for this purpose and why? Thanks.
11
by: raylopez99 | last post by:
I just downloaded the apparently free SDK for DirectX 9, all 200+ MB of it, but as I read about WPF I wonder: is DirectX obsolete? Should I even bother learning how to use it? After all, the end...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.