From: Martijn K. on 20 Sep 2008 10:58 Hi all, This is the first time I actually post in this group, and I'm new to win32 programming so please bear with me. First off, I'm using win32 api (C++) for a little program. I have a main window generated by a resource file, with several child controls (static control, edit control, buttons, etc.). I'm trying to achieve horizontal scrolling text (ticker?) in one of the static text controls. I've tried things like SetDlgItemText() in a loop with spaces and the like, totally inefficient. I think there is a better (and cleaner) way of accomplishing this! Could anyone point me in the right direction? Thanks in advance! Greetings, Martijn
From: Christian ASTOR on 20 Sep 2008 11:17 Martijn K. wrote: > I'm trying to achieve horizontal scrolling text (ticker?) in one of the > static text controls. > I've tried things like SetDlgItemText() in a loop with spaces and the > like, totally inefficient. > I think there is a better (and cleaner) way of accomplishing this! Could > anyone point me in the right direction? Use BitBlt() and double-buffering to transfer a vertical band of bits from left to right, with a multimedia timer for smooth scrolling (timeSetEvent())
From: Bob Masta on 21 Sep 2008 07:55 On Sat, 20 Sep 2008 17:17:08 +0200, Christian ASTOR <castorix(a)club-internet.fr> wrote: >Martijn K. wrote: > >> I'm trying to achieve horizontal scrolling text (ticker?) in one of the >> static text controls. >> I've tried things like SetDlgItemText() in a loop with spaces and the >> like, totally inefficient. >> I think there is a better (and cleaner) way of accomplishing this! Could >> anyone point me in the right direction? > >Use BitBlt() and double-buffering to >transfer a vertical band of bits from left to right, >with a multimedia timer for smooth scrolling (timeSetEvent()) This is undoubtedly the smoothest approach, but if you want a simpler first step you could use a timer (multimedia or simple SetTimer) and on each tick drop one old character from one end of your string and add one new character to the other, and show with SetDlgItemText. This will be a bit jerky with a proportional font, so you might want to use a fixed pitch. But it should be much simpler to get going from where you are now. Best regards, Bob Masta DAQARTA v4.00 Data AcQuisition And Real-Time Analysis www.daqarta.com Scope, Spectrum, Spectrogram, Sound Level Meter FREE Signal Generator Science with your sound card!
From: Martijn K. on 21 Sep 2008 21:22 Bob Masta schreef: > On Sat, 20 Sep 2008 17:17:08 +0200, Christian > ASTOR <castorix(a)club-internet.fr> wrote: > >> Martijn K. wrote: >> >>> I'm trying to achieve horizontal scrolling text (ticker?) in one of the >>> static text controls. >>> I've tried things like SetDlgItemText() in a loop with spaces and the >>> like, totally inefficient. >>> I think there is a better (and cleaner) way of accomplishing this! Could >>> anyone point me in the right direction? >> Use BitBlt() and double-buffering to >> transfer a vertical band of bits from left to right, >> with a multimedia timer for smooth scrolling (timeSetEvent()) > > This is undoubtedly the smoothest approach, but if > you want a simpler first step you could use a > timer (multimedia or simple SetTimer) and on each > tick drop one old character from one end of your > string and add one new character to the other, and > show with SetDlgItemText. This will be a bit > jerky with a proportional font, so you might want > to use a fixed pitch. But it should be much > simpler to get going from where you are now. > > Best regards, > > > Bob Masta > > DAQARTA v4.00 > Data AcQuisition And Real-Time Analysis > www.daqarta.com > Scope, Spectrum, Spectrogram, Sound Level Meter > FREE Signal Generator > Science with your sound card! Thank you for your answers, Bob and Christian! This clears up a lot. I'm actually going to look further into GDI. The functions it provides seem very interesting for (simple) animating. I'll try both of your ways for getting scrolling text. Regards, Martijn
From: Jerry Coffin on 22 Sep 2008 02:39
In article <3097$48d50f85$5352be89$20666(a)cache110.multikabel.net>, Tinuskooremans(a)casema.nl says... > Hi all, > > This is the first time I actually post in this group, and I'm new to > win32 programming so please bear with me. > First off, I'm using win32 api (C++) for a little program. I have a main > window generated by a resource file, with several child controls (static > control, edit control, buttons, etc.). > I'm trying to achieve horizontal scrolling text (ticker?) in one of the > static text controls. > I've tried things like SetDlgItemText() in a loop with spaces and the > like, totally inefficient. > I think there is a better (and cleaner) way of accomplishing this! Could > anyone point me in the right direction? For this, I think the static control is more hindrance than help. I'd start by blitting your entire text content to a bitmap. I'd then blit an appropriate-sized chunk from that bitmap to the screen, then update the position from which you blit in the source bitmap. To do the scrolling, you'll (for example) set a timer, and in it invalidate the rectangle where you're scrolling your text. You'll also want to avoid erasing the background in that area to avoid "flashing" artifacts from drawing two different colors in quick succession (it's unecessary, since your blit will cover the entire area anyway. I suppose the politically correct method would be to use ScrollWindow to move the text, and only blit in new data in the slice that ScrollWindow left uncovered. At one time, this would have given enough improvement in speed and efficiency to be worthwhile, but nowadays I doubt it's worth the trouble unless you run into a problem. -- Later, Jerry. The universe is a figment of its own imagination. |