Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Static Scrolling Text
#1
I figured out how to make text scroll in a static txt of a dialog but it requires a lot of setwintext

Is there an easier to make txt do this?


Thanks
#2
Use read-only edit control instead.
#3
Oh sorry i didn't make myself clear

When i say scroll i mean make the text go across a static text
like the text moves kind of like a electronic billboard

Thanks
#4
Function dlg_static_scroll
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_static_scroll" &dlg_static_scroll)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54000000 0x20000 4 4 118 32 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030004 "" "" ""

ret
;messages
int-- y
str-- s
sel message
,case WM_INITDIALOG
,s.getmacro("dlg_static_scroll")
,;s.setwintext(id(3 hDlg))
,SetTimer hDlg 1 50 0
,
,case WM_TIMER
,sel wParam
,,case 1
,,;this works but only with edit controls and scrolls whole line
,,;SendMessage id(3 hDlg) WM_VSCROLL SB_LINEDOWN 0
,,
,,;this does not work
,,;ScrollWindowEx id(3 hDlg) 0 -1 0 0 0 0 SW_ERASE|SW_INVALIDATE
,,;UpdateWindow id(3 hDlg)
,,;;RedrawWindow id(3 hDlg) 0 0 RDW_INVALIDATE|RDW_ERASE
,,
,,;this works
,,int h=id(3 hDlg)
,,RECT r; GetClientRect(h &r); r.top=y; y-1
,,__MemBmp mb.Create(r.right r.bottom)
,,FillRect mb.dc &r COLOR_BTNFACE+1
,,SetBkMode mb.dc TRANSPARENT
,,int f0=SelectObject(mb.dc GetStockObject(DEFAULT_GUI_FONT))
,,
,,DrawTextW mb.dc @s -1 &r DT_WORDBREAK|DT_EXPANDTABS|DT_NOPREFIX
,,
,,SelectObject(mb.dc f0)
,,
,,int dc=GetDC(h)
,,BitBlt dc 0 0 r.right r.bottom mb.dc 0 0 SRCCOPY
,,ReleaseDC(h dc)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#5
2 more questions

How do you make it repeat

and can you make it go left to right also?


Thanks
#6
horizontal
Function dlg_static_scroll_hor
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_static_scroll_hor" &dlg_static_scroll_hor)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54000000 0x20000 4 4 114 13 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030004 "" "" ""

ret
;messages
int-- x
str-- s
sel message
,case WM_INITDIALOG
,s="DrawTextW mb.dc @s -1 &r DT_EXPANDTABS|DT_NOPREFIX"
,SetTimer hDlg 1 10 0
,x=-1000000000 ;;begin scroll from right
,
,case WM_TIMER
,sel wParam
,,case 1
,,int h=id(3 hDlg)
,,RECT r; GetClientRect(h &r)
,,__MemBmp mb.Create(r.right r.bottom)
,,FillRect mb.dc &r COLOR_BTNFACE+1
,,SetBkMode mb.dc TRANSPARENT
,,int f0=SelectObject(mb.dc GetStockObject(DEFAULT_GUI_FONT))
,,
,,r.left=x; x-1 ;;scroll by 1 pixel
,,RECT rr; DrawTextW mb.dc @s -1 &rr DT_EXPANDTABS|DT_NOPREFIX|DT_CALCRECT ;;calc text width
,,if(x<=-rr.right) x=r.right ;;repeat when all text scrolled
,,
,,DrawTextW mb.dc @s -1 &r DT_EXPANDTABS|DT_NOPREFIX ;;draw text
,,
,,SelectObject(mb.dc f0)
,,
,,int dc=GetDC(h)
,,BitBlt dc 0 0 r.right r.bottom mb.dc 0 0 SRCCOPY
,,ReleaseDC(h dc)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

vertical
Function dlg_static_scroll
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_static_scroll" &dlg_static_scroll)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54000000 0x20000 4 4 118 32 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030004 "" "" ""

ret
;messages
int-- y
str-- s
sel message
,case WM_INITDIALOG
,s.getmacro("dlg_static_scroll"); s.fix(findl(s 8))
,s.rtrim("[]")
,y=-1000000000 ;;begin scroll from bottom
,SetTimer hDlg 1 50 0
,
,case WM_TIMER
,sel wParam
,,case 1
,,int h=id(3 hDlg)
,,RECT r; GetClientRect(h &r)
,,__MemBmp mb.Create(r.right r.bottom)
,,FillRect mb.dc &r COLOR_BTNFACE+1
,,SetBkMode mb.dc TRANSPARENT
,,int f0=SelectObject(mb.dc GetStockObject(DEFAULT_GUI_FONT))
,,
,,r.top=y; y-1 ;;scroll by 1 pixel
,,RECT rr; rr.right=r.right
,,DrawTextW mb.dc @s -1 &rr DT_WORDBREAK|DT_EXPANDTABS|DT_NOPREFIX|DT_CALCRECT ;;calc text height
,,if(y<=-rr.bottom) y=r.bottom ;;repeat when all text scrolled
,,
,,DrawTextW mb.dc @s -1 &r DT_WORDBREAK|DT_EXPANDTABS|DT_NOPREFIX
,,
,,;if line wrapping not needed, remove DT_WORDBREAK| from both DrawTextW
,,
,,SelectObject(mb.dc f0)
,,
,,int dc=GetDC(h)
,,BitBlt dc 0 0 r.right r.bottom mb.dc 0 0 SRCCOPY
,,ReleaseDC(h dc)
,,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#7
That is awesome bro

Thanks so much
#8
Hi once again, i seem to be having trouble making this do what i wish
Once the text has completely scrolled, i would like it to stop, for some reason i cant get this to work right
Here is the code so far(just Timer part)

Function 3_Dialog
Code:
Copy      Help
,case WM_TIMER
,sel wParam
,,case 1
,,int hh=id(19 hDlg)
,,RECT r; GetClientRect(hh &r)
,,__MemBmp mb.Create(r.right r.bottom)
,,FillRect mb.dc &r COLOR_BTNFACE+1
,,SetBkMode mb.dc TRANSPARENT
,,int f0=SelectObject(mb.dc GetStockObject(DEFAULT_GUI_FONT))
,,r.left=xx; xx-1
,,RECT rr; DrawTextW mb.dc @ScrollText -1 &rr DT_EXPANDTABS|DT_NOPREFIX|DT_CALCRECT ;;calc text width
,,if(xx<=-rr.right) xx=r.right
,,
,,DrawTextW mb.dc @ScrollText -1 &r DT_EXPANDTABS|DT_NOPREFIX
,,SelectObject(mb.dc f0)
,,int dc=GetDC(hh)
,,BitBlt dc 0 0 r.right r.bottom mb.dc 0 0 SRCCOPY
,,ReleaseDC(hh dc)
,,if(xx = 5)
,,,out "Complete Scroll"
,,,NEED STOP CODE HERE


When the xx = 5, it has completed it scroll enough for me to stop it
I basically just need to know how to make TIMER stop so the text will stop moving
Thanks very much
#9
KillTimer hDlg wParam
#10
Thanks so much
I knew it was something like that from earlier readings
I was thinking DestroyTimer or something though

Thanks again Smile
#11
I love the vertical scroll dialog. So cool!!!!
Thanks for helping us with all our requests and continuing to make QM an amazing evolving magic toolkit!
Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)