Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2007-06

Repainting the whole screen

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

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

Reply by email