The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: m-tek on October 13, 2007, 06:43:54 PM

Title: Simple Marquee Text
Post by: m-tek on October 13, 2007, 06:43:54 PM
Ok ive got some code that displays a marquee type text in text box


<DATA> TEXT dd 0
<CODE> .IF TEXT == 6
<CODE>      MOV TEXT, 7
Func GameStatus.SetText 'WELCOME'
<CODE> .ELSEIF TEXT == 5
<CODE>      MOV TEXT, 6
Func GameStatus.SetText 'WELCOM'
<CODE> .ELSEIF TEXT == 4
<CODE>      MOV TEXT, 5
Func GameStatus.SetText 'WELCO'
<CODE> .ELSEIF TEXT == 3
<CODE>      MOV TEXT, 4
Func GameStatus.SetText 'WELC'
<CODE> .ELSEIF TEXT == 2
<CODE>      MOV TEXT, 3
Func GameStatus.SetText 'WEL'
<CODE> .ELSEIF TEXT == 1
<CODE>      MOV TEXT, 2
Func GameStatus.SetText 'WE'
<CODE> .ELSEIF TEXT == 0
<CODE>      MOV TEXT, 1
Func GameStatus.SetText 'W'
<CODE> .endif


Is there a single line command instead of this long winded way

cheers
Title: Re: Simple Marquee Text
Post by: MichaelW on October 13, 2007, 10:36:44 PM
I assume that by "text box" you mean an edit control. I know of no single-line command that will do this in an edit control. If I were doing this I think I would use  SetWindowText (http://msdn2.microsoft.com/en-us/library/ms633546.aspx), or in a dialog  SetDlgItemText (http://msdn2.microsoft.com/en-us/library/ms645521.aspx), to update the edit control, and do the update in response to a  WM_TIMER notification (http://msdn2.microsoft.com/en-us/library/ms644902.aspx) from a timer set up with  SetTimer (http://msdn2.microsoft.com/en-us/library/ms644906.aspx). The marquee effect would be achieved by varying the starting point in the message string. The message string would be defined something like this:

mymsg db "         welcome",0

With the number of leading spaces slightly more than the character width of the edit control. The starting point could be stored in a dword variable, with the value effectively the offset, in characters, from the start of the string to the first character to display. The value of the variable would start at zero, be incremented each time the timer fired, and be reset to zero whenever it reached the end of the string. The value passed to SetDlgItemText in the lpString parameter would be the offset address of the message string plus the value of the variable. Using a fixed-pitch font would make it easier to determine the character width of the edit control, and improve the appearance by eliminating variations in the apparent scroll rate.
Title: Re: Simple Marquee Text
Post by: m-tek on October 13, 2007, 11:22:07 PM
Thanks for the prompt reply ....some things to look at there

BTW Im using a timer to control it at the minute

TY