News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Double buffering with GDI+

Started by Airam, July 25, 2009, 06:51:40 PM

Previous topic - Next topic

Airam

Hello...again.

I'm trying to draw a rectangle with the mouse over other draws.
This is my repaint proc:


repaint Proc hWnd:HWND
Local graphics:DWord
   Local ps:PAINTSTRUCT
   Local StaticRect:RECT

   Invoke BeginPaint, hWnd, Addr ps
   Mov StaticHDC, Eax
   Invoke GdipCreateFromHDC, StaticHDC, Addr graphics
   Invoke GdipCreateFromHWND, hWnd, Addr graphics
   Invoke GetClientRect, hWnd, Addr StaticRect
   Invoke FillRect, StaticHDC, Addr StaticRect, BoardPen
   Invoke GdipCreateFontFromLogfontA, StaticHDC, Addr logfont, Addr gpfont
        invoke drawgrid, graphics
        .If startSelection == 1
      Invoke drawZoomSelection, graphics, zoomX1, zoomY1, zoomX2, zoomY2
   .EndIf
        Invoke EndPaint, hWnd, Addr ps
   Ret
repaint EndP


The problem is that the screen starts to flick when i draw the rectangle with the mouse over the grid. How do I use double buffer with GDI+??

Thanks in advance!!



dedndave

i have seen previous threads on this subject
try using the forum search function and look for "flicker"
EDIT
i think it was Hutch that had the solution
you might use advanced search and limit responses to posts by Hutch-- and get a shorter list

Astro

Hi,

It appears you draw the image in memory then display the result, as opposed to drawing to the screen directly (slower).

http://www.codeproject.com/KB/GDI-plus/gdiplus.aspx

An example in C++ (only shows double-buffering part).

Best regards,
Astro.

MichaelW

The example that I posted here does all of the drawing on a bitmap in memory, and copies the entire bitmap to the client area of the dialog each time the client area is repainted. In that example the drawing is done only once in the WM_INITDIALOG handler. There is a GeneSys mouse draw example (that uses GDI) included in the attachment here that does all of the drawing on a bitmap in memory, and copies the entire bitmap to the client area of the dialog each time the client area is repainted (note that the repaint is forced in the WM_MOUSEMOVE handler).
eschew obfuscation