[fpc-devel] Repainting the whole screen

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Sun Jun 24 13:27:40 CEST 2007


Hello,

I am implementing a magnifying tool with overlays on Windows. I draw
my overlay using DirectX, move it, etc, but when I move it the windows
behind it are not repainted, so I see some corrupted images.

Now, I was trying to figure out how can I tell all the visible windows
on the screen to repaint themselves. But this seams harder then I
initially thougth ... I tryed invalidating the desktop window and
sending a message to it. But that doesn´t work.

I should probably post this on ms newsgroups, but no-one answered my
last questions there, so I don't have much hope anyone would answer
this.

procedure RepaintScreen();
var
  screenDC: HDC;
  screenRect: RECT;
begin
  // DC for the screen
  screenDC := GetWindowDC(GetDesktopWindow);

  screenRect.left := 0;
  screenRect.top := 0;
  screenRect.right := mPluginData.GlassWidth^;
  screenRect.bottom := mPluginData.GlassHeight^;

  InvalidateRect(screenDC, screenRect, True);

  DeleteDC(screenDC);

  SendMessage(GetDesktopWindow(), WM_PAINT, 0, 0);
end;

I also tryed to iterate througth all windows and tell them all to repaint:

procedure RepaintScreen();
var
  wndDC: HDC;
  screenRect: RECT;
  Wnd: HWnd;
begin
  Wnd := GetWindow(GetDesktopWindow(), gw_HWndFirst);
  while Wnd <> 0 do
  begin
    wndDC := GetWindowDC(Wnd);

    screenRect.left := 0;
    screenRect.top := 0;
    screenRect.right := mPluginData.GlassWidth^;
    screenRect.bottom := mPluginData.GlassHeight^;

    InvalidateRect(wndDC, screenRect, True);

    DeleteDC(wndDC);

    SendMessage(Wnd, WM_PAINT, 0, 0);

    Wnd := GetWindow(Wnd, gw_HWndNext)
  end
end;

but nothing works.

thanks,
-- 
Felipe Monteiro de Carvalho



More information about the fpc-devel mailing list