News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

End of line character with TextOut

Started by Squeeto, May 12, 2007, 03:36:40 PM

Previous topic - Next topic

Squeeto

Hi, sorry to be back so soon.
There seems to be many subtleties with assembler programming.

How do I get rid of the bold vertical bar (end of line character) that textout displays.


MyText1 db "This will display pi to a billion decimal places.",0


...


WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hdc:HDC
LOCAL ps:PAINTSTRUCT
LOCAL rect:RECT
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov    hdc,eax
invoke GetClientRect,hWnd, ADDR rect
                invoke GetSysColor,COLOR_BTNFACE
                invoke SetBkColor,hdc,eax
                invoke TextOut,hdc,100,60,ADDR MyText,SIZEOF MyText
invoke EndPaint,hWnd, ADDR ps
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor    eax,eax
ret
WndProc endp

Thank you

Tedd

It's just the zero at the end of the string - give length-1 to TextOut (SIZEOF MyText-1)

Usually, the zero is used at the end of a string to indicte the end, but since you give the length to TextOut it doesn't need/want a zero at the end, but if you give a length which happens to include it then it'll try to print it.
No snowflake in an avalanche feels responsible.

Squeeto

That worked, thanks.
I actually had considered to try this but I wasn't sure if it was proper technique.