Whats the first message sent to a window once the its created?

I'm using this in my window and seem to still be having problems with my thread not always showing my graphics.

_In my main thread____


invoke GetDC,hWnd ;<< OWN_DC in window creation data
mov hdc,eax
invoke SetICMMode,hdc,ICM_ON
invoke CreateCompatibleDC,hdc
mov cdc,eax
invoke SetICMMode,cdc,ICM_ON

mov eax,OFFSET ThreadProc
invoke CreateThread,NULL,NULL,eax,\
mov Threadh,eax

invoke CloseHandle,Threadh


Whats happening in the thread below is the LineTo drawing sometimes does not apper. I was guessing it might have something to do with message priority.

Any help appreciated.


;my thread

ThreadProc PROC USES ebx hhwnd:DWORD
mov BMID,35
GETDIM ;<< a macro

mov eax,BMH
mov SBMH,eax
mov eax,BMW
shr eax,1
mov SBMW,eax
invoke GetClientRect, hhwnd,addr rect;hhwnd
mov eax,rect.right
sub eax,SBMW
shr eax,1
mov SXPOS,eax
sub eax,1
mov XBOXS,eax
add eax,1
add eax,SBMW
add eax,1
mov XBOXE,eax
mov eax,YPOS
mov SYPOS,eax
add SYPOS ,30
xor edx,edx
mov ebx,SBMW

invoke CreatePen,PS_SOLID,1,0FFFh
mov mypen,eax
invoke SelectObject,hdc,mypen
mov oldpen,eax
invoke MoveToEx,hdc,XBOXS,29,NULL
invoke LineTo,hdc, XBOXE,29
invoke LineTo,hdc,XBOXE, 75
invoke LineTo,hdc,XBOXS,75
invoke LineTo,hdc,XBOXS,29
invoke SelectObject,hdc,oldpen
invoke DeleteObject,mypen


mov var1, 0
.while var1 < ebx;<< Bitmap width
invoke BitBlt,hdc,SXPOS,SYPOS,SBMW,SBMH,cdc,var1,0,SRCCOPY
invoke GetTickCount
mov var2, eax
add var2, 10 ; nominal milliseconds delay

.while eax < var2
invoke GetTickCount

add var1,1

jmp bla

ThreadProc endp
Posted on 2001-10-15 22:39:11 by titan
Even if the window procedure receives a msg before the WM_CREATE , this is the one you have to process if you want to do start-up stuff.
Posted on 2001-10-16 00:35:43 by latigo
When you get WM_CREATE, the window is still hidden. Your second thread is probably, during certain runs, drawing before the window has been set to a visible state.

I guess it's one of the pitfalls of not doing all your drawing during WM_PAINT.
Posted on 2001-10-16 20:05:56 by tank
Very informative.....thanx

I solved the problem by creating the thread suspended and then i switch in on after with a menu item "new" that starts my game.

Just bad programming on my part.

Posted on 2001-10-16 21:39:04 by titan