News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Difference in WM_PAINT messages ?

Started by gelatine1, June 29, 2014, 04:48:03 AM

Previous topic - Next topic

dedndave

in your WM_PAINT code, you use EBX and EDI without preserving them   :P

dedndave

something screwy with the text loop

to test it, i jumped around it - and the screen is black again   :P
jmp around

mov edx,[FirstLine]
__NextLine:
mov eax,edx
mov ecx,[BytesPerLine]
mov ebx,eax
shl ebx,7
push edx
mul [LineHeight]
pop edx
;mov edx,[CurrentLine]
add ebx,[pmem]
push edx
invoke ExtTextOut, memdc,3,eax,ETO_OPAQUE or ETO_NUMERICSLATIN,addr rect,ebx,[ecx+4*edx],NULL
pop edx
inc edx
mov eax,[LastLine]
cmp eax,edx
jns __NextLine

around:

gelatine1

I changed the GetOutlineTextMetrics function to this

mov outtxt.otmSize,SIZEOF OUTLINETEXTMETRIC
invoke GetOutlineTextMetrics,hdc,SIZEOF OUTLINETEXTMETRIC,offset outtxt


nothing changed

I preserved ebx and edi like this:

cmp eax,WM_PAINT
jnz __cont0
push ebx
push edi

...

pop edi
pop ebx


Nothing changed :( I'm kinda lost in all this

And okay  :t I'll find what's going wrong in the text loop

gelatine1

This ETO_OPAQUE flag in the ExtTextOut function messed everything up.
I have a black background again  :biggrin: But... this happens:



i set the text to red so it doesn't get hidden in the backgrounds :p

What is this ? another flag that should be altered ? or um oh right I need to use SetBkgndColor to black I guess ?

EDIT: SetBkColor did the thing :) although there is still something wrong with the LineHeight now. Can't seem to get it right

dedndave

even though you filled in the bitmap with all black, you still have to set the background color for ExtTextOut
invoke  SetBkColor,memdc,0

http://msdn.microsoft.com/en-us/library/dd162713%28v=vs.85%29.aspx

QuoteThe ExtTextOut function draws text using the currently selected font, background color,
and text color. You can optionally provide dimensions to be used for clipping, opaquing, or both.

dedndave

the line height thing is probably a clipping issue
to test that theory, try it without clipping

but, i think your clipping rectangle isn't moving with your text

gelatine1

May I ask , what is clipping? Do you know any article about it ?

Thanks in advance, I hope I'm not bothering you too much

dedndave

well - clipping is like "not drawing outside this rectangle"
for example - your text is wider than the area you want to display it - you clip it
in this case, you are not using clipping - you don't have that flag set in ExtTextOut
so - you don't really need a rectangle pointer, either (also used for opaquing)

but - that's not where the problem lies
the problem lies here, with the calculation of the top of the rect for InvalidateRect   :biggrin:

mov ecx,[CurrentLine]
shl ecx,7
mov edx,[pmem]
add edx,ecx

mov ecx,[CurrentLine]
mov ebx,[BytesPerLine]
mov ebx,[ebx+4*ecx]

mov [edx+ebx],eax

inc ebx
mov edx,[BytesPerLine]
mov [edx+4*ecx],ebx

mov rect.left,0
shl ecx,4
mov rect.top,ecx
mov rect.right,4FFh
add ecx,16
mov rect.bottom,ecx
invoke InvalidateRect,hWnd,offset rect,0

dedndave

you can test it very easily....

type 4 lines of text - notice that each line is shorter   :P

now, minimize the window - then restore it
this causes the OS to send a WM_PAINT message with the entire client area as the update region

dedndave

you have to use the LineHeight variable in that calculation   :t

dedndave


gelatine1

Thanks a lot once again dave. You have been really helpful so thank you for all of that :) I finally got everything working well again.

Tedd

A few suggestions..

mov dword ptr [esi+4],CS_HREDRAW or CS_VREDRAW
This can actually be zeroed -- these flags cause the WHOLE window to be redrawn every time the size changes, which will result in flicker.

Using the BLACK_BRUSH for the window background is perfectly fine, flicker is caused by the background being cleared unnecessarily. Specifically, when you call InvalidateRect, the last parameter is true/false to say whether you want the background cleared in the invalidated rectangle; setting it to false means it won't be cleared, which is fine as long as you're drawing entirely over the area so no previous pixels remain - which you are, with BitBlt.


invoke GlobalAlloc,GHND,65535
mov hmem,eax
invoke GlobalLock,hmem
mov pmem,eax

can simply be:

invoke GlobalAlloc,GPTR,65535
mov pmem,eax

and to free:
invoke GlobalFree,pmem
Equally for BytesPerLine.
There's no need to lock/unlock, it's a left-over from windows 3.
Potato2