Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDI fast scroll

Tags:

scroll

winapi

gdi

I use GDI to create some custom textwidget. I draw directly to the screen, unbuffered.

now i'd like to implement some fast scrolling, that simply pixelshifts the respective part of the framebuffer (and only redraws the newly visible lines).

I noticed that for example the rich text controls does it like this. If i use some GDI drawing functions to directly draw to the framebuffer, over a rich text control, and then scroll the rich text, it will also scroll my drawing along with the text. so i assume the rich text simply pixelshifts it's part of the framebuffer.

I'd like to do the same, but don't know how to do so.

Can someone help? (independant of programming language))

thanks!

like image 234
genesys Avatar asked Dec 29 '22 15:12

genesys


2 Answers

The ScrollWindowEx() API function is optimized to do this.

like image 186
Hans Passant Avatar answered Dec 31 '22 05:12

Hans Passant


See BitBlt function:

The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.

and the example at the end of its documentation: Capturing an Image:

You can use a bitmap to capture an image, and you can store the captured image in memory, display it at a different location in your application's window. [...] In some cases, you may want your application to capture images and store them only temporarily. [...] To store an image temporarily, your application must call CreateCompatibleDC to create a DC that is compatible with the current window DC. After you create a compatible DC, you create a bitmap with the appropriate dimensions by calling the CreateCompatibleBitmap function and then select it into this device context by calling the SelectObject function.

After the compatible device context is created and the appropriate bitmap has been selected into it, you can capture the image. The BitBlt function captures images. This function performs a bit block transfer that is, it copies data from a source bitmap into a destination bitmap. [...] To redisplay the image, call BitBlt a second time, specifying the compatible DC as the source DC and a window DC as the target DC.

like image 33
Bill Avatar answered Dec 31 '22 03:12

Bill