|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
rotate gdi objecthi, im trying to rotate a gdi drawn object on my form with a
keypress....forinstance when i push the down arrow, for it to rotate the object drawn until the top is down, or if i push the right arrow key, to rotate the object until its pointed to the right. i tried using a drawing matrix to accomplish this, but all it did was rotate my entire form (im drawing my object on the back of the form) and thats not what i need. I need it to rotate on the spot, so i tried RotateAt but that also didnt work...how can i accomplish what im looking for? thanks -- -iwdu15 Hi,
Maybe this will help. I added a picturebox to a form and have it draw an image in the paint event. The point that the image is rotated about is the center of the image. I added a timer so every 100 miliseconds it redraws the image rotated 30 degrees. Imports System.Drawing.Drawing2D Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint Static bm As Bitmap Static intAngle As Integer = 0 If bm Is Nothing Then bm = New Bitmap(16, 16) Dim g As Graphics = Graphics.FromImage(bm) g.Clear(Color.White) g.DrawLine(Pens.Red, 0, 0, 16, 16) g.DrawLine(Pens.Blue, 0, 16, 16, 0) End If e.Graphics.TranslateTransform(50, 50) e.Graphics.RotateTransform(intAngle) e.Graphics.DrawImage(bm, -8, -8) intAngle += 30 If intAngle > 360 Then intAngle -= 360 End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick PictureBox1.Invalidate() End Sub End Class Ken ------------------------ Show quoteHide quote "iwdu15" <jmmgoalsteratyahoodotcom> wrote in message news:2012967F-F328-4DD3-96AD-88646CE08AB2@microsoft.com... > hi, im trying to rotate a gdi drawn object on my form with a > keypress....forinstance when i push the down arrow, for it to rotate the > object drawn until the top is down, or if i push the right arrow key, to > rotate the object until its pointed to the right. i tried using a drawing > matrix to accomplish this, but all it did was rotate my entire form (im > drawing my object on the back of the form) and thats not what i need. I > need > it to rotate on the spot, so i tried RotateAt but that also didnt > work...how > can i accomplish what im looking for? > > thanks > > -- > -iwdu15
Summary of issues with VS 2005
2 keys pressed at once VB.NET wizard form .Net 2.0 - Webbrowser control flickering on resize.... Loading UserControl on a ShowDialog Form sequence strange Access SubQuery Help Needed..................... VS2005 combox question Project help bindaing a DATE field ListView vs. ListBox in my Program |
|||||||||||||||||||||||