Restored from previous forum. Originally posted by Justin.
Has anyone tried to make a rolling credits text?, that is scroll some lines of text from bottom to top (like the credits in a movie).
i'm thinking to use a listbox and scroll it, but maybe is too crapy.
wich is the best way to do this, is there any code out there?
thanks.
Rolling credits text
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
Try searching the forums for something like "scrolling area". It shows an example of making a scrollable area inside a window with gadgets inside it. However, you could probably print some text to the area and move it every time round a loop.
You would need to refresh the text I think (or better - use text gadgets) but it should work.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
Try searching the forums for something like "scrolling area". It shows an example of making a scrollable area inside a window with gadgets inside it. However, you could probably print some text to the area and move it every time round a loop.
You would need to refresh the text I think (or better - use text gadgets) but it should work.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by clx.
here some code for scrolling in a directx window.. maybe you could use this? also maybe you could work with it to repeat over and over again as I haven't worked with doing that yet..
- clx
here some code for scrolling in a directx window.. maybe you could use this? also maybe you could work with it to repeat over and over again as I haven't worked with doing that yet..
Code: Select all
If InitSprite() = 0 MessageRequester("Error", "Can't open DirectX 7 Or later", 0)
End
EndIf
LoadFont (0, "tahoma", 8)
Dim scroll.s(5)
scroll(0) = "here is some scrolling text in a"
scroll(1) = "directx window with purebasic!"
scroll(2) = ""
scroll(3) = "here is some more scrolling text!!"
scroll(4) = "bye............"
scroll_hWnd = OpenWindow(0, 0, 0, 300, 180, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "scrolling text")
If OpenWindowedScreen(scroll_hWnd, 0, 0, 300, 180, 0, 0, 0) = 0
MessageRequester("Error","Failed to open DirectX Window", #MB_ICONERROR)
End
EndIf
Repeat
Select WindowEvent()
Case #PB_EventCloseWindow
End
EndSelect
If IsScreenActive()
FlipBuffers()
ClearScreen(0,0,0)
If StartDrawing(ScreenOutput())
DrawingMode(1)
DrawingFont(FontID())
FrontColor(255, 255, 255)
y = 180
y1 - 1
For s = 0 To 5
Delay(15)
Locate(35, y+y1)
y+15
DrawText(scroll(s))
Next
StopDrawing()
EndIf
EndIf
Until EventID = #PB_EventCloseWindow-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by effigy.
From what I read justin, you want this credits to be on a Window.
For example to use in an About area in a program.
Below is code to get you started. This code halts execution while it's running.
But I think you can create it in another embedded window. But you will
need the windowsex library from the resource site to do that.
;- Window Constants
;
#Window_0 = 0
;- Gadget Constants
;
#Gadget_0 = 5
;- Image Plugins
;- Image Globals
#image1=10
LoadFont(2,"Arial",10)
Global texttoscroll.s
texttoscroll="This is line 1"
Procedure typetext(startpos)
CreateImage(#image1, 300,200)
UseImage(#image1)
StartDrawing(ImageOutput())
DrawingMode(1)
FrontColor(255,255,255)
Box(0, 0, 300, 200)
FrontColor(53,80,125)
UseFont(2)
DrawingFont(FontID())
Locate(15,startpos)
DrawText(texttoscroll)
StopDrawing()
EndProcedure
If OpenWindow(#Window_0, 216, 0, 450, 300, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
If CreateGadgetList(WindowID())
typetext(200)
ImageGadget(#Gadget_0, 70, 35,300,200, UseImage(#image1),#PB_Image_Border)
For x=1 To 200 Step 1
typetext(200-x)
SetGadgetState(#gadget_0, UseImage(#image1))
Delay(15)
Next
EndIf
EndIf
Repeat
evnt=WaitWindowEvent()
If evnt=#wm_close
quit=1
EndIf
Until quit=1
End
Hope that helps
Derek
From what I read justin, you want this credits to be on a Window.
For example to use in an About area in a program.
Below is code to get you started. This code halts execution while it's running.
But I think you can create it in another embedded window. But you will
need the windowsex library from the resource site to do that.
;- Window Constants
;
#Window_0 = 0
;- Gadget Constants
;
#Gadget_0 = 5
;- Image Plugins
;- Image Globals
#image1=10
LoadFont(2,"Arial",10)
Global texttoscroll.s
texttoscroll="This is line 1"
Procedure typetext(startpos)
CreateImage(#image1, 300,200)
UseImage(#image1)
StartDrawing(ImageOutput())
DrawingMode(1)
FrontColor(255,255,255)
Box(0, 0, 300, 200)
FrontColor(53,80,125)
UseFont(2)
DrawingFont(FontID())
Locate(15,startpos)
DrawText(texttoscroll)
StopDrawing()
EndProcedure
If OpenWindow(#Window_0, 216, 0, 450, 300, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
If CreateGadgetList(WindowID())
typetext(200)
ImageGadget(#Gadget_0, 70, 35,300,200, UseImage(#image1),#PB_Image_Border)
For x=1 To 200 Step 1
typetext(200-x)
SetGadgetState(#gadget_0, UseImage(#image1))
Delay(15)
Next
EndIf
EndIf
Repeat
evnt=WaitWindowEvent()
If evnt=#wm_close
quit=1
EndIf
Until quit=1
End
Hope that helps
Derek
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Justin.
Thanks guys for the fast response.
@effigy, sorry but your code does not scroll the text when i run it, i'm missing something?
@clx, that example is very good, do you know how to start the text at the bottom again when it has disapeared from the top, to have it always rolling?
i like to work with the API directly, i'll try to transale it to the GDI , will post it if i succed.
Thanks guys for the fast response.
@effigy, sorry but your code does not scroll the text when i run it, i'm missing something?
@clx, that example is very good, do you know how to start the text at the bottom again when it has disapeared from the top, to have it always rolling?
i like to work with the API directly, i'll try to transale it to the GDI , will post it if i succed.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ebs.
Justin,
Effigy's code works fine for me, but, as he said, it halts execution while it's running. Here is a version that uses a timer instead of a delay loop. This allows the program to work while the text is scrolling. With this method, you can move the window while the text scrolls.
Regards,
Eric
Justin,
Effigy's code works fine for me, but, as he said, it halts execution while it's running. Here is a version that uses a timer instead of a delay loop. This allows the program to work while the text is scrolling. With this method, you can move the window while the text scrolls.
Regards,
Eric
Code: Select all
;- Window Constants
;
#Window_0 = 0
;- Gadget Constants
;
#Gadget_0 = 5
;- Image Globals
#image1=10
Declare TimerCallback()
LoadFont(2,"Arial",10)
Global texttoscroll.s
texttoscroll="This is line 1"
Global TextPos.l
Procedure typetext(startpos)
CreateImage(#image1, 300,200)
UseImage(#image1)
StartDrawing(ImageOutput())
DrawingMode(1)
FrontColor(255,255,255)
Box(0, 0, 300, 200)
FrontColor(53,80,125)
UseFont(2)
DrawingFont(FontID())
Locate(15,startpos)
DrawText(texttoscroll)
StopDrawing()
EndProcedure
If OpenWindow(#Window_0, 216, 0, 450, 300, #PB_Window_SystemMenu, "New window ( 0 )")
If CreateGadgetList(WindowID())
TextPos = 200
typetext(TextPos)
ImageGadget(#Gadget_0, 70, 35,300,200, UseImage(#image1),#PB_Image_Border)
; start timer
StartTimer(1, 15, @TimerCallBack())
Repeat
evnt=WaitWindowEvent()
If evnt=#wm_close
quit=1
EndIf
Until quit=1
EndIf
EndIf
End
Procedure TimerCallback()
; display text
typetext(TextPos)
SetGadgetState(#gadget_0, UseImage(#image1))
; move up
TextPos - 1
; stop when text reaches top
If TextPos < 0
EndTimer(1)
EndIf
EndProcedure
Originally posted by Justin
Thanks guys for the fast response.
@effigy, sorry but your code does not scroll the text when i run it, i'm missing something?
@clx, that example is very good, do you know how to start the text at the bottom again when it has disapeared from the top, to have it always rolling?
i like to work with the API directly, i'll try to transale it to the GDI , will post it if i succed.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Justin.
Thanks ebs, i did an api version using a timer too, flickers a little, i think it should be better using bitblit_(), maybe i try it.
Thanks ebs, i did an api version using a timer too, flickers a little, i think it should be better using bitblit_(), maybe i try it.
Code: Select all
#TM_DRAW=1
spt.PAINTSTRUCT
src.RECT
global spt,src,hinst,ypos
hinst=getmodulehandle_(0)
ypos=350
dim scroll.s(5)
scroll(0) = "here is some scrolling text in a"
scroll(1) = "dialog window with purebasic!"
scroll(2) = ""
scroll(3) = "here is some more scrolling text!!"
scroll(4) = "bye............"
;Dialog Procedure
procedure Dialogproc(hdlg,msg,wparam,lparam)
select msg
case #WM_INITDIALOG
getclientrect_(hdlg,@src)
src\right=(src\right)/2
settimer_(hdlg,#TM_DRAW,15,#null)
hdc=getdc_(hdlg)
SetBkMode_(hdc,#TRANSPARENT)
retval=1
case #WM_TIMER
ypos-1
if ypos=-100 : ypos=350 : endif
invalidaterect_(hdlg,@src,#true)
retval=1
case #WM_PAINT
hdc=beginpaint_(hdlg,@spt)
for s=0 to 4
TextOut_(hdc,10,ypos+yinc,scroll(s),len(scroll(s)))
yinc+20
next
endpaint_(hdlg,@spt)
retval=1
case #WM_CLOSE
EndDialog_(hdlg,1)
retval=1
default
retval=0
endselect
procedurereturn retval
endprocedure
;Show dialog (Modal)
DialogBoxIndirectParam_(hinst,?dialogdata,0,@Dialogproc(),0)
end
;DIALOG TEMPLATE (Modal)
datasection
dialogdata:
data.b 193,0,200,20, 0,0,0,1, 0,0, 100,0, 43,0, 112,1, 217,0
data.b 0,0, 0,0, 87,0,105,0,110,0,100,0,111,0,119,0,49,0,0,0, 1,0, 77,0,83,0,32,0,83,0,97,0,110,0,115,0,32,0,83,0,101,0,114,0,105,0,102,0,0,0
enddatasection
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm