View Single Post
Old 04-11-2019, 10:00 AM   #2
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

cfillion suggested this approach:

Quote:
Originally Posted by cfillion View Post
An extension can draw after REAPER (except in some cases where it appears to be repainting directly, eg. the playback cursor) by intercepting the WM_PAINT window message.


(Red=WM_PAINT, Green=js_ReaScript API redrawing at reaper.defer's 30Hz)

https://gist.github.com/cfillion/0d3...688175ec0026f1
... and it works perfectly on Linux and macOS!

Unfortunately, on WindowsOS, it still glitches. I therefore tried to get REAPER to draw into an offscreen memory bitmap instead of the screen, so that this bitmap and the script's LICE bitmap can be composited before blitting to the screen. WM_PAINT can optionally point to a memory bitmap in its WPARAM parameter, but code such as this didn't work, so I suspect that REAPER's windows ignore the WPARAM pointer:
Code:
RECT r{0,0,0,0};
GetClientRect(hwnd, &r);
HDC clientDC = GetDC(hwnd);
HDC memDC = CreateCompatibleDC(clientDC);
HBITMAP memBitmap = CreateCompatibleBitmap(clientDC, r.right, r.bottom);
SelectObject(memDC, memBitmap);

LRESULT result = SendMessage(hwnd, WM_PAINT, (WPARAM)memDC, lParam);

AlphaBlend LICE into memDC;

BitBlt(clientDC, 0, 0, r.right, r.bottom, memDC, 0, 0, SRCCOPY);

DeleteObject( memBitmap );
DeleteDC( memDC );
Changing WM_PAINT into WM_PRINT or WM_PRINTCLIENT didn't work either (or at least, not with the options that I tried).

Last edited by juliansader; 04-11-2019 at 10:41 AM.
juliansader is offline   Reply With Quote