diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-16 17:37:21 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-16 17:37:21 -0400 |
| commit | d5f9c237b7e81e54e91241d49d2a8ad718bd397c (patch) | |
| tree | ee7d4c75c05b1b2144f83f7f07c1e20bcea6eab3 /redo/imagelist_windows.c | |
| parent | 5d69bc2534cd3a90a2c93c564c2fcfc5accd5fad (diff) | |
Added image lists to Tables and added them to the Windows backend... mostly. There are a few kinks to work out...
Diffstat (limited to 'redo/imagelist_windows.c')
| -rw-r--r-- | redo/imagelist_windows.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/redo/imagelist_windows.c b/redo/imagelist_windows.c index 434190c..dcea7a1 100644 --- a/redo/imagelist_windows.c +++ b/redo/imagelist_windows.c @@ -36,10 +36,10 @@ HIMAGELIST newImageList(int width, int height) return il; } -void addImage(HIMAGELIST il, HBITMAP bitmap, int origwid, int oright, int width, int height) +void addImage(HIMAGELIST il, HWND hwnd, HBITMAP bitmap, int origwid, int oright, int width, int height) { BOOL wasScaled = FALSE; - HDC scaledDC, origDC; + HDC winDC, scaledDC, origDC; HBITMAP scaled; HBITMAP prevscaled, prevorig; @@ -49,33 +49,38 @@ void addImage(HIMAGELIST il, HBITMAP bitmap, int origwid, int oright, int width, goto noscale; } wasScaled = TRUE; - scaledDC = GetDC(NULL); + winDC = GetDC(hwnd); + if (winDC == NULL) + xpanic("error getting DC for window", GetLastError()); + origDC = CreateCompatibleDC(winDC); + if (winDC == NULL) + xpanic("error getting DC for original ImageList bitmap", GetLastError()); + prevorig = SelectObject(origDC, bitmap); + if (prevorig == NULL) + xpanic("error selecting original ImageList bitmap into DC", GetLastError()); + scaledDC = CreateCompatibleDC(origDC); if (scaledDC == NULL) - xpanic("error getting screen DC for scaled ImageList bitmap", GetLastError()); - scaled = CreateCompatibleBitmap(scaledDC, width, height); + xpanic("error getting DC for scaled ImageList bitmap", GetLastError()); + scaled = CreateCompatibleBitmap(origDC, width, height); if (scaled == NULL) xpanic("error creating scaled ImageList bitmap", GetLastError()); prevscaled = SelectObject(scaledDC, scaled); if (prevscaled == NULL) - xpanic("error selecting scaled ImageList bitmap into screen DC", GetLastError()); - origDC = GetDC(NULL); - if (origDC == NULL) - xpanic("error getting screen DC for original ImageList bitmap", GetLastError()); - prevorig = SelectObject(origDC, bitmap); - if (prevorig == NULL) - xpanic("error selecting original ImageList bitmap into screen DC", GetLastError()); + xpanic("error selecting scaled ImageList bitmap into DC", GetLastError()); if (StretchBlt(scaledDC, 0, 0, width, height, origDC, 0, 0, origwid, oright, SRCCOPY) == 0) xpanic("error scaling ImageList bitmap down", GetLastError()); if (SelectObject(origDC, prevorig) != bitmap) - xpanic("error selecting previous bitmap into original image's screen DC", GetLastError()); + xpanic("error selecting previous bitmap into original image's DC", GetLastError()); if (DeleteDC(origDC) == 0) - xpanic("error deleting original image's screen DC", GetLastError()); + xpanic("error deleting original image's DC", GetLastError()); if (SelectObject(scaledDC, prevscaled) != scaled) - xpanic("error selecting previous bitmap into scaled image's screen DC", GetLastError()); + xpanic("error selecting previous bitmap into scaled image's DC", GetLastError()); if (DeleteDC(scaledDC) == 0) - xpanic("error deleting scaled image's screen DC", GetLastError()); + xpanic("error deleting scaled image's DC", GetLastError()); + if (DeleteDC(winDC) == 0) + xpanic("error deleting window DC", GetLastError()); noscale: if ((*fv_ImageList_Add)(il, scaled, NULL) == -1) @@ -84,3 +89,10 @@ noscale: if (DeleteObject(scaled) == 0) xpanic("error deleting scaled bitmap", GetLastError()); } + +void applyImageList(HWND hwnd, UINT uMsg, WPARAM wParam, HIMAGELIST il) +{ + if (SendMessageW(hwnd, uMsg, wParam, (LPARAM) il) == (LRESULT) NULL) +;// xpanic("error setting image list", GetLastError()); + // TODO free old one here if any +} |
