PDA

Click to See Complete Forum and Search --> : Alright, who's gonna ge this one?


Ephesians
May 1st, 2002, 02:52 PM
Private Function Laser(picBild As PictureBox, StartX As Integer, StartY As Integer, StandLeft As Integer, StandRight As Integer, sFarbe As String)

Dim iZahl, iZahl2 As Integer
Dim sFarbe2 As String

Me.ScaleMode = vbPixels

With picBild
.ScaleMode = vbPixels
.AutoRedraw = True
End With

For iZahl2 = 0 To picBild.ScaleWidth
For iZahl = 0 To picBild.ScaleHeight
sFarbe2 = picBild.Point(iZahl2, iZahl)
Line (StartX, StartY)-(StandLeft + iZahl2, StandRight + iZahl), sFarbe2

Next
Line (StartX, StartY)-(StandLeft + iZahl2, StandRight + picBild.ScaleHeight), sFarbe
Next

For iZahl2 = 0 To picBild.ScaleHeight
Line (StartX, StartY)-(StandLeft + picBild.ScaleWidth, StandRight + iZahl2), sFarbe
Next

End Function


Private Sub Command1_Click()
Laser Picture1, 700, 500, Picture1.left, Picture1.Top, Me.BackColor

End Sub


Here's the problem:

The form opens and I click on the command button. The first time the function draws the picture, it draws it at co-ordinates 1200, 60 which is nowhere near the picture! Every subsequent push of the button draws it in the correct location which is 80,60. Why is it pulling this phantom co-ordinate from for the first run?

Fox
May 1st, 2002, 03:41 PM
This sounds like a unit conversion problem..

I'm right, put the Scalemode of your form and picture to 3 in design mode, it'll work just fine. If you want to do it by code put the unit changing in Form_Load or something...

SLH
May 1st, 2002, 03:47 PM
Nice effect BTW :)

McCain
May 1st, 2002, 09:59 PM
Looks like a guy (or girl) from Germany... =)
Wie geht's?

If you don't mind me asking, what do you use this cool effect for?

Fox
May 2nd, 2002, 04:29 AM
Or Switzerlad :) Hoi!

Well this would be better done using the LineTo API (way faster) ... however, you can make cool menus like this if you just move the lines along the borders (or "burn" the letters with lasers ;))

Ephesians
May 2nd, 2002, 11:40 AM
The problem with using the LineTo api is that the last pixel of the line is always blank. Therefore the picture erases itself as it draws. I tried to use that api and couldn't seem to get it to work.
If you can figure out how to use the lineto api for that could I would appreciate seeing it. I didn't create the code by the way, I just got it off vbcode.com.