Here is my thread that scrolls a bitmap in my window. I decided i wanted to set some bits also with SetPixel. However it just won't set the pixels no matter what i try. I can make a pen and it works fine for drawing but i can't set a pixel. If anyone has time check this code and see if they see something wrong.

ThanxThreadProc PROC USES ebx Param:DWORD
LOCAL var3:DWORD,var2:DWORD,var1:DWORD,tb:DWORD


mov var3, 0
invoke LoadBitmap,hInstance,35
mov hBitmap,eax
invoke SelectObject,cdc,hBitmap
mov obitmap,eax
invoke CreatePen,PS_SOLID,0,666h
mov mypen,eax
invoke SelectObject,hdc,mypen
invoke LineTo,hdc,300,200

.while tb < 500
invoke SetPixel,hdc,tb,40,666h ;(right here)
inc tb
.endw


bla:

mov ebx,BMW
mov var1, 0
.while var1 < ebx ;<< Bitmap width
invoke BitBlt,hdc,XPOS,YPOS,BMW,BMH,cdc,var1,0,SRCCOPY


invoke GetTickCount
mov var2, eax
add var2, 10 ; nominal milliseconds delay

.while eax < var2
invoke GetTickCount
.endw

add var1,2
.endw

jmp bla


ThreadProc ENDP
Posted on 2001-09-09 16:57:15 by titan
I think the BitBlt may be overwriting the drawing that SetPixels does. Try instead putting the SetPixel loop after the BitBlt call

Unless that is you want to draw to the bitmap, then change the hdc parameter of the SetPixel call to cdc
Posted on 2001-09-09 17:15:02 by Eóin
thanks zadkiel but i found out through trial and error that local variables have to be initialized...ay least in the case of my code


the solution was :

mov tb,0

right after the local declarations

hey live and learn

your suggestion did give me some new ideas though

thanx:alright:
Posted on 2001-09-09 19:54:45 by titan