[PATCH 0/1] MR2204: ole32: Support HBITMAP format in DataCache_GetExtent and DataCache_Draw
Fix can't insert any HBITMAP in RichEdit control -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2204
From: Tingzhong Luo <luotingzhong(a)uniontech.com> Fix can't insert any HBITMAP in RichEdit control --- dlls/ole32/datacache.c | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c index b3216992af5..880e7eb361b 100644 --- a/dlls/ole32/datacache.c +++ b/dlls/ole32/datacache.c @@ -2130,6 +2130,31 @@ static HRESULT WINAPI DataCache_Draw( GlobalUnlock( cache_entry->stgmedium.u.hGlobal ); return S_OK; } + case CF_BITMAP: + { + HDC comp_dc; + HBITMAP* bm; + + if ((cache_entry->stgmedium.tymed != TYMED_GDI) || + !((bm = GlobalLock( cache_entry->stgmedium.u.hBitmap )))) + continue; + + comp_dc = CreateCompatibleDC(hdcDraw); + if (comp_dc) + { + HBITMAP hprev_bmp; + + hprev_bmp = SelectObject(comp_dc, *bm); + BitBlt(hdcDraw, lprcBounds->left, lprcBounds->top, + lprcBounds->right - lprcBounds->left, lprcBounds->bottom - lprcBounds->top, + comp_dc, 0, 0, SRCCOPY); + SelectObject(comp_dc, hprev_bmp); + DeleteDC(comp_dc); + } + + GlobalUnlock( cache_entry->stgmedium.u.hBitmap ); + return S_OK; + } } } @@ -2359,6 +2384,47 @@ static HRESULT WINAPI DataCache_GetExtent( GlobalUnlock( cache_entry->stgmedium.u.hGlobal ); + return S_OK; + } + case CF_BITMAP: + { + HDC hdc; + char dst_bmibuf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *dst_info; + HBITMAP *bm; + LONG x_pels_m, y_pels_m; + + if ((cache_entry->stgmedium.tymed != TYMED_GDI) || + !((bm = GlobalLock( cache_entry->stgmedium.u.hBitmap )))) + continue; + + hdc = GetDC(NULL); + dst_info = (BITMAPINFO *)dst_bmibuf; + + memset(dst_info, 0, sizeof(char)*FIELD_OFFSET( BITMAPINFO, bmiColors[256] )); + dst_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + + GetDIBits(hdc, *bm, 0, 1, NULL, dst_info, DIB_RGB_COLORS); + + x_pels_m = dst_info->bmiHeader.biXPelsPerMeter; + y_pels_m = dst_info->bmiHeader.biYPelsPerMeter; + + /* Size in units of 0.01mm (ie. MM_HIMETRIC) */ + if (x_pels_m != 0 && y_pels_m != 0) + { + lpsizel->cx = dst_info->bmiHeader.biWidth * 100000 / x_pels_m; + lpsizel->cy = dst_info->bmiHeader.biHeight * 100000 / y_pels_m; + } + else + { + lpsizel->cx = dst_info->bmiHeader.biWidth * 2540 / GetDeviceCaps( hdc, LOGPIXELSX ); + lpsizel->cy = dst_info->bmiHeader.biHeight * 2540 / GetDeviceCaps( hdc, LOGPIXELSY ); + } + + ReleaseDC(0, hdc); + + GlobalUnlock( cache_entry->stgmedium.u.hBitmap ); + return S_OK; } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2204
When a `CF_BITMAP` is loaded into the cache, a synthesised `CF_DIB` should have been created. `Draw()` and `GetExtent()` should then find this. So why isn't this happening? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2204#note_24345
This merge request was closed by Tingzhong Luo. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2204
I am apologized for trying to apply a patch which is out-of-date, the patch is related to this bug report: [Cann't insert any HBITMAP in RichEdit control](https://bugs.winehq.org/show_bug.cgi?id=42892) The demo of attachment in bug report works without any problem in wine 7.20, this bug report should be fix in early version and can be closed. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2204#note_25243
participants (3)
-
Huw Davies (@huw) -
Tingzhong Luo -
Tingzhong Luo (@tzluo)