The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Squeeto on May 12, 2007, 03:36:40 PM

Title: End of line character with TextOut
Post by: Squeeto on May 12, 2007, 03:36:40 PM
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
Title: Re: End of line character with TextOut
Post by: Tedd on May 12, 2007, 07:48:38 PM
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.
Title: Re: End of line character with TextOut
Post by: Squeeto on May 13, 2007, 07:09:43 AM
That worked, thanks.
I actually had considered to try this but I wasn't sure if it was proper technique.