[CLIPBRD]

Handle WM_PALETTECHANGED and WM_QUERYNEWPALETTE: realizes any palette found on the clipboard, if there is any, if it receives one of those messages.

svn path=/trunk/; revision=70329
This commit is contained in:
Hermès Bélusca-Maïto 2015-12-12 20:40:19 +00:00
parent 1153d6397c
commit e19711eebf
3 changed files with 75 additions and 0 deletions

View file

@ -407,6 +407,30 @@ static LRESULT WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
break;
}
case WM_QUERYNEWPALETTE:
{
if (RealizeClipboardPalette(hWnd) != GDI_ERROR)
{
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
return TRUE;
}
return FALSE;
}
case WM_PALETTECHANGED:
{
if ((HWND)wParam != hWnd)
{
if (RealizeClipboardPalette(hWnd) != GDI_ERROR)
{
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
}
}
break;
}
default:
{
return DefWindowProc(hWnd, uMsg, wParam, lParam);

View file

@ -156,3 +156,53 @@ void PlayEnhMetaFileFromClipboard(HDC hdc, const RECT *lpRect)
hEmf = GetClipboardData(CF_ENHMETAFILE);
PlayEnhMetaFile(hdc, hEmf, lpRect);
}
UINT RealizeClipboardPalette(HWND hWnd)
{
HPALETTE hPalette;
HPALETTE hOldPalette;
UINT uResult;
HDC hDevContext;
if (!OpenClipboard(NULL))
{
return GDI_ERROR;
}
if (!IsClipboardFormatAvailable(CF_PALETTE))
{
CloseClipboard();
return GDI_ERROR;
}
hPalette = GetClipboardData(CF_PALETTE);
if (!hPalette)
{
CloseClipboard();
return GDI_ERROR;
}
hDevContext = GetDC(hWnd);
if (!hDevContext)
{
CloseClipboard();
return GDI_ERROR;
}
hOldPalette = SelectPalette(hDevContext, hPalette, FALSE);
if (!hOldPalette)
{
ReleaseDC(hWnd, hDevContext);
CloseClipboard();
return GDI_ERROR;
}
uResult = RealizePalette(hDevContext);
SelectPalette(hDevContext, hOldPalette, FALSE);
ReleaseDC(hWnd, hDevContext);
CloseClipboard();
PlayEnhMetaFile(hdc, hEmf, lpRect);
}

View file

@ -15,3 +15,4 @@ void BitBltFromClipboard(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nH
void SetDIBitsToDeviceFromClipboard(UINT uFormat, HDC hdc, int XDest, int YDest, int XSrc, int YSrc, UINT uStartScan, UINT fuColorUse);
void PlayMetaFileFromClipboard(HDC hdc, const RECT *lpRect);
void PlayEnhMetaFileFromClipboard(HDC hdc, const RECT *lpRect);
UINT RealizeClipboardPalette(HWND hWnd);