Re: Baffled or Buffered?
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 11:17:05 -0000
"WebBiz" <justask@xxxxxxxxxxxxxxxxx> wrote in message news:ZlDDf.8962$oG.1723@xxxxxxxxxxxxx
Code posted Mike.
Okay Rick, but first you'll need to forgive me for giving you my "standard waffle" about the posting of code samples ;-)
I pasted your code into a VB Module and Form and the first thing I had to do was to "fix" all the lines that "turned red" in my code window because they had been "line wrapped" in your post. You really need to break such lines into smaller pieces (using "space / underscore") if your own email program breaks long lines. Then of course it still wouldn't run because you had used your own names for the Form and the Picture Box. Then after I fixed that it still wouldn't run because of references to certain vcariables and things that were outside of the posted code and which were therefore not present in my test program. What I'm trying to say is that such things put a lot of people off (they certainly put me off) and they don't then bother to even attempt to answer your question because of it. What I'm trying to say is that if you have a problem then you really should create a new VB app (using the default names for all controls you use) and then paste and modify your code into it until it runs (and obviously displays the problem you are having), making sure that any "outside variables" it references are instead included in the sample code. That way people will find it easy to paste your code into a new VB project and run it straight away, and so they'll be far more likely to take the time to look at your problem and post an answer.
Okay, "rant" over. Down to business ;-) . . . . . As I said, I couldn't get your own code running without a lot of messing about, but your description of what you are attempting to do was good and so I decided to instead write a small test app of my own to do the job you describe. I think the following is what you are after. Post again if it is not and I'll have another look. There are ways of doing it that are a little bit faster, but the following routine using standard VB functions works well on my own system, so I think it will on yours too. Start a new project and paste the code into a VB Form containing a picture box. Then change the hard coded path ("c:\tulips.bmp") to a bitmap (or jpeg) that exists on your own system. Try it out and let me know if it is the sort of thing you are after.
Mike
Option Explicit Private drawing As Boolean
Private Sub drawlines(ClickPos As Single) Dim wide As Single, high As Single, X As Single wide = Picture1.ScaleWidth high = Picture1.ScaleHeight If Picture1.ScaleX _ (ClickPos, Picture1.ScaleMode, vbPixels) < 2 Then Exit Sub Picture1.Cls For X = 0 To wide Step ClickPos Picture1.Line (X, 0)-(X, high), vbRed Next X End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.PaintPicture LoadPicture("c:\tulips.bmp"), _
0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
Picture1.Picture = Picture1.Image
End SubPrivate Sub Picture1_Mousedown(Button As Integer, _ Shift As Integer, X As Single, Y As Single) drawing = True drawlines (X) End Sub
Private Sub Picture1_MouseMove(Button As Integer, _ Shift As Integer, X As Single, Y As Single) If drawing = True Then drawlines (X) End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
drawing = False
End Sub
.
- Follow-Ups:
- Re: Baffled or Buffered?
- From: WebBiz
- Re: Baffled or Buffered?
- From: Mike Williams
- Re: Baffled or Buffered?
- References:
- Baffled or Buffered?
- From: WebBiz
- Re: Baffled or Buffered?
- From: Mike Williams
- Re: Baffled or Buffered?
- From: WebBiz
- Re: Baffled or Buffered?
- From: WebBiz
- Baffled or Buffered?
- Prev by Date: Re: minor annoyance number 1
- Next by Date: Re: Baffled or Buffered?
- Previous by thread: Re: Baffled or Buffered?
- Next by thread: Re: Baffled or Buffered?
- Index(es):