Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > API > Pixels not permanent after setpixel in picturebox ?


Reply
 
Thread Tools Display Modes
  #1  
Old 02-07-2003, 02:37 AM
Garmour's Avatar
Garmour Garmour is offline
Back for a little while..

Retired Leader
* Expert *
 
Join Date: Oct 2002
Location: Behind you.....Boo
Posts: 2,199
Default Pixels not permanent after setpixel in picturebox ?


I'm just curious about this.
I was setting pixels in a picture box various colours (it's actually a fractal). The box gets filled with these pixels, but if anything obscures the box (ie, if another window get focus, or I drag the picbox off screen and back again) the pixels are lost.
This also happens if I draw my 'zoom in' box over the picbox (it's just a shape control).

Now, I've cured this using bitblt (that was fun!!) but I wanted to know why the setpixel didn't permanently (during runtime) remain in the picbox ?
Reply With Quote
  #2  
Old 02-07-2003, 02:58 AM
shmoove shmoove is offline
Senior Contributor

Retired Leader
* Expert *
 
Join Date: Sep 2002
Location: Israel
Posts: 918
Default

AutoRedraw = True?
I put this code on a form that has AutoRedraw = True and ScaleMode = vbPixels:
Code:
Option Explicit Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long Private Sub Command1_Click() Dim i As Long, h As Long h = Me.ScaleHeight / 2 For i = 0 To Me.ScaleWidth SetPixel Me.hdc, i, h, vbBlue Next i Me.Refresh End Sub
and the line is permanent.
You could also put the drawing in the Paint event, set AutoRedraw to False and omit the Me.Refresh at the end.
__________________
Have you tried looking right in front of you (or at least in MSDN)?
Reply With Quote
  #3  
Old 02-07-2003, 05:44 AM
Garmour's Avatar
Garmour Garmour is offline
Back for a little while..

Retired Leader
* Expert *
 
Join Date: Oct 2002
Location: Behind you.....Boo
Posts: 2,199
Default

haha,
From your reference to autodraw I was able to find the key word I've been missing (persistant).

It's a bit frustrating that I went to the trouble of using bitblt instead of just being able to change the autoredraw!!!

But, it's not all bad 'cause I'm going to have to use bitblt to 'animate' my colour cycling.

Thanks shmoove.
__________________

....but then, what would I know ?
Reply With Quote
  #4  
Old 02-07-2003, 05:46 AM
Garmour's Avatar
Garmour Garmour is offline
Back for a little while..

Retired Leader
* Expert *
 
Join Date: Oct 2002
Location: Behind you.....Boo
Posts: 2,199
Default

In fact, I must have changed the autoredraw as part of the change to bitblt without realising the reasons. Doh!!
__________________

....but then, what would I know ?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->