Implement SS_CENTERIMAGE for static control.
This commit is contained in:
parent
1e92f4a3c7
commit
6b85523c59
@ -134,7 +134,7 @@ static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
prevIcon = (HICON)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hicon );
|
prevIcon = (HICON)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hicon );
|
||||||
if (hicon)
|
if (hicon && !(style & SS_CENTERIMAGE))
|
||||||
{
|
{
|
||||||
SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
|
SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
|
||||||
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
|
||||||
@ -158,7 +158,7 @@ static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
hOldBitmap = (HBITMAP)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hBitmap );
|
hOldBitmap = (HBITMAP)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hBitmap );
|
||||||
if (hBitmap)
|
if (hBitmap && !(style & SS_CENTERIMAGE))
|
||||||
{
|
{
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
GetObjectW(hBitmap, sizeof(bm), &bm);
|
GetObjectW(hBitmap, sizeof(bm), &bm);
|
||||||
@ -322,7 +322,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
else
|
else
|
||||||
hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam);
|
hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam);
|
||||||
/* FIXME : should we also return the previous hIcon here ??? */
|
/* FIXME : should we also return the previous hIcon here ??? */
|
||||||
STATIC_SetIcon(hwnd, hIcon, style);
|
STATIC_SetIcon(hwnd, hIcon, full_style);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SS_BITMAP:
|
case SS_BITMAP:
|
||||||
@ -332,7 +332,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
hBitmap = STATIC_LoadBitmapW(hwnd, (LPCWSTR)lParam);
|
hBitmap = STATIC_LoadBitmapW(hwnd, (LPCWSTR)lParam);
|
||||||
else
|
else
|
||||||
hBitmap = STATIC_LoadBitmapA(hwnd, (LPCSTR)lParam);
|
hBitmap = STATIC_LoadBitmapA(hwnd, (LPCSTR)lParam);
|
||||||
STATIC_SetBitmap(hwnd, hBitmap, style);
|
STATIC_SetBitmap(hwnd, hBitmap, full_style);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SS_LEFT:
|
case SS_LEFT:
|
||||||
@ -406,7 +406,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
case STM_SETIMAGE:
|
case STM_SETIMAGE:
|
||||||
switch(wParam) {
|
switch(wParam) {
|
||||||
case IMAGE_BITMAP:
|
case IMAGE_BITMAP:
|
||||||
lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, style );
|
lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
|
||||||
break;
|
break;
|
||||||
case IMAGE_CURSOR:
|
case IMAGE_CURSOR:
|
||||||
FIXME("STM_SETIMAGE: Unhandled type IMAGE_CURSOR\n");
|
FIXME("STM_SETIMAGE: Unhandled type IMAGE_CURSOR\n");
|
||||||
@ -415,7 +415,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
FIXME("STM_SETIMAGE: Unhandled type IMAGE_ENHMETAFILE\n");
|
FIXME("STM_SETIMAGE: Unhandled type IMAGE_ENHMETAFILE\n");
|
||||||
break;
|
break;
|
||||||
case IMAGE_ICON:
|
case IMAGE_ICON:
|
||||||
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, style );
|
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam);
|
FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam);
|
||||||
@ -426,7 +426,7 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||||||
|
|
||||||
case STM_SETICON16:
|
case STM_SETICON16:
|
||||||
case STM_SETICON:
|
case STM_SETICON:
|
||||||
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, style );
|
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
|
||||||
InvalidateRect( hwnd, NULL, TRUE );
|
InvalidateRect( hwnd, NULL, TRUE );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -513,6 +513,8 @@ static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
|
|||||||
|
|
||||||
if (style & SS_NOPREFIX)
|
if (style & SS_NOPREFIX)
|
||||||
wFormat |= DT_NOPREFIX;
|
wFormat |= DT_NOPREFIX;
|
||||||
|
if (style & SS_CENTERIMAGE)
|
||||||
|
wFormat |= DT_VCENTER;
|
||||||
|
|
||||||
if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET ))) SelectObject( hdc, hFont );
|
if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET ))) SelectObject( hdc, hFont );
|
||||||
|
|
||||||
@ -579,13 +581,26 @@ static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
|
|||||||
RECT rc;
|
RECT rc;
|
||||||
HBRUSH hbrush;
|
HBRUSH hbrush;
|
||||||
HICON hIcon;
|
HICON hIcon;
|
||||||
|
INT x, y;
|
||||||
|
|
||||||
GetClientRect( hwnd, &rc );
|
GetClientRect( hwnd, &rc );
|
||||||
hbrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
|
hbrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
|
||||||
(WPARAM)hdc, (LPARAM)hwnd );
|
(WPARAM)hdc, (LPARAM)hwnd );
|
||||||
FillRect( hdc, &rc, hbrush );
|
FillRect( hdc, &rc, hbrush );
|
||||||
if ((hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
|
hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
|
||||||
DrawIcon( hdc, rc.left, rc.top, hIcon );
|
if (style & SS_CENTERIMAGE)
|
||||||
|
{
|
||||||
|
CURSORICONINFO *info = hIcon ? (CURSORICONINFO *)GlobalLock16(HICON_16(hIcon)) : NULL;
|
||||||
|
x = (rc.right - rc.left)/2 - (info ? info->nWidth/2 : 0);
|
||||||
|
y = (rc.bottom - rc.top)/2 - (info ? info->nHeight/2 : 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = rc.left;
|
||||||
|
y = rc.top;
|
||||||
|
}
|
||||||
|
if (hIcon)
|
||||||
|
DrawIcon( hdc, x, y, hIcon );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
|
static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
|
||||||
@ -599,13 +614,26 @@ static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
|
|||||||
|
|
||||||
if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
|
if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
|
||||||
{
|
{
|
||||||
|
INT x, y;
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
|
|
||||||
if(GetObjectType(hBitmap) != OBJ_BITMAP) return;
|
if(GetObjectType(hBitmap) != OBJ_BITMAP) return;
|
||||||
if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
|
if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
|
||||||
GetObjectW(hBitmap, sizeof(bm), &bm);
|
GetObjectW(hBitmap, sizeof(bm), &bm);
|
||||||
oldbitmap = SelectObject(hMemDC, hBitmap);
|
oldbitmap = SelectObject(hMemDC, hBitmap);
|
||||||
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
|
if (style & SS_CENTERIMAGE)
|
||||||
|
{
|
||||||
|
RECT rcClient;
|
||||||
|
GetClientRect(hwnd, &rcClient);
|
||||||
|
x = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
|
||||||
|
y = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
|
||||||
SRCCOPY);
|
SRCCOPY);
|
||||||
SelectObject(hMemDC, oldbitmap);
|
SelectObject(hMemDC, oldbitmap);
|
||||||
DeleteDC(hMemDC);
|
DeleteDC(hMemDC);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user