winapi - Using BitBlt to Scroll Text over a Picture Backrgound -
my user-control intended operate smooth vertical text scroller. renders text (to scrolled) control's surface only once, using textrenderer.drawtext
. starts timer, upon each of ticks, bit-blits (bitblt
) entire client-rectangle 1 pixel up. control's device-context both source , destination of bitblt
operation, follows:
protected sub handletimertick(byval sender system.object, byval e system.eventargs) dim og graphics = me.creategraphics() dim shdc intptr = og.gethdc() dim ires integer = bitblt(shdc, 0, 0, me.clientrectangle.size.width, me.clientrectangle.size.height, shdc, 0, 1, srccopy) og.releasehdc(shdc) og.dispose() end sub
this accomplishes desired scroll effect, but if control's background solid-color (e.g. me.backcolor = color.gray
).
if set picture control's background, bitblt
scrolls background along text displayed on it. ofcourse, i'd text scrolled, , background image remain static.
i have found following thread, suggests using transparentblt
instead of bitblt
background solid uniform color ignored : how copy bitblt?
the solution suggested there not suitable case on hand, in colorful background used.
please note text of solid uniform color.
your advice appreciated. if of matter, i'm using vb.net 2005.
if background supposed stay fixed while text moves around on it, suggest maintain 2 separate bitmaps: 1 contains background image, , second 1 contain text on transparent background.
then, on each timer tick, draw background bitmap first , draw text bitmap @ desired offset position.
i don't understand why need p/invoke bitblt
function this. what's wrong equivalent gdi+ function, wrapped .net framework graphics.drawimage
?
Comments
Post a Comment