2018-02-08 11:37:23 +01:00
|
|
|
/*
|
|
|
|
* Static control
|
|
|
|
*
|
|
|
|
* Copyright David W. Metcalfe, 1993
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* - Controls with SS_SIMPLE but without SS_NOPREFIX:
|
|
|
|
* The text should not be changed. Windows doesn't clear the
|
|
|
|
* client rectangle, so the new text must be larger than the old one.
|
|
|
|
* - The SS_RIGHTJUST style is currently not implemented by Windows
|
|
|
|
* (or it does something different than documented).
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* - Animated cursors
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "commctrl.h"
|
2022-01-24 08:47:33 +01:00
|
|
|
#include "uxtheme.h"
|
2018-02-08 11:37:23 +01:00
|
|
|
|
2020-02-10 09:31:39 +01:00
|
|
|
#include "wine/heap.h"
|
2018-02-08 11:37:23 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "comctl32.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(static);
|
|
|
|
|
|
|
|
static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style );
|
|
|
|
static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style );
|
|
|
|
static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style );
|
|
|
|
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style );
|
|
|
|
static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, DWORD style );
|
|
|
|
static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, DWORD style );
|
|
|
|
static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style );
|
|
|
|
|
2020-02-10 09:31:39 +01:00
|
|
|
struct static_extra_info
|
|
|
|
{
|
|
|
|
HFONT hfont;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
HICON hicon;
|
|
|
|
HBITMAP hbitmap;
|
|
|
|
HENHMETAFILE hemf;
|
|
|
|
} image;
|
2020-02-10 09:31:41 +01:00
|
|
|
BOOL image_has_alpha;
|
2020-02-10 09:31:39 +01:00
|
|
|
};
|
2018-02-08 11:37:23 +01:00
|
|
|
|
|
|
|
typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style );
|
|
|
|
|
|
|
|
static const pfPaint staticPaintFunc[SS_TYPEMASK+1] =
|
|
|
|
{
|
|
|
|
STATIC_PaintTextfn, /* SS_LEFT */
|
|
|
|
STATIC_PaintTextfn, /* SS_CENTER */
|
|
|
|
STATIC_PaintTextfn, /* SS_RIGHT */
|
|
|
|
STATIC_PaintIconfn, /* SS_ICON */
|
|
|
|
STATIC_PaintRectfn, /* SS_BLACKRECT */
|
|
|
|
STATIC_PaintRectfn, /* SS_GRAYRECT */
|
|
|
|
STATIC_PaintRectfn, /* SS_WHITERECT */
|
|
|
|
STATIC_PaintRectfn, /* SS_BLACKFRAME */
|
|
|
|
STATIC_PaintRectfn, /* SS_GRAYFRAME */
|
|
|
|
STATIC_PaintRectfn, /* SS_WHITEFRAME */
|
|
|
|
NULL, /* SS_USERITEM */
|
|
|
|
STATIC_PaintTextfn, /* SS_SIMPLE */
|
|
|
|
STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
|
|
|
|
STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
|
|
|
|
STATIC_PaintBitmapfn, /* SS_BITMAP */
|
|
|
|
STATIC_PaintEnhMetafn, /* SS_ENHMETAFILE */
|
|
|
|
STATIC_PaintEtchedfn, /* SS_ETCHEDHORZ */
|
|
|
|
STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
|
|
|
|
STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
|
|
|
|
};
|
|
|
|
|
2020-02-10 09:31:39 +01:00
|
|
|
static struct static_extra_info *get_extra_ptr( HWND hwnd, BOOL force )
|
|
|
|
{
|
|
|
|
struct static_extra_info *extra = (struct static_extra_info *)GetWindowLongPtrW( hwnd, 0 );
|
|
|
|
if (!extra && force)
|
|
|
|
{
|
|
|
|
extra = heap_alloc_zero( sizeof(*extra) );
|
|
|
|
if (extra)
|
|
|
|
SetWindowLongPtrW( hwnd, 0, (ULONG_PTR)extra );
|
|
|
|
}
|
|
|
|
return extra;
|
|
|
|
}
|
|
|
|
|
2018-02-08 11:37:23 +01:00
|
|
|
static BOOL get_icon_size( HICON handle, SIZE *size )
|
|
|
|
{
|
|
|
|
ICONINFO info;
|
|
|
|
BITMAP bmp;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!GetIconInfo(handle, &info))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ret = GetObjectW(info.hbmColor, sizeof(bmp), &bmp);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
size->cx = bmp.bmWidth;
|
|
|
|
size->cy = bmp.bmHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteObject(info.hbmMask);
|
|
|
|
DeleteObject(info.hbmColor);
|
|
|
|
|
|
|
|
return !!ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* STATIC_SetIcon
|
|
|
|
*
|
|
|
|
* Set the icon for an SS_ICON control.
|
|
|
|
*/
|
|
|
|
static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style )
|
|
|
|
{
|
|
|
|
HICON prevIcon;
|
|
|
|
SIZE size;
|
2020-02-10 09:31:39 +01:00
|
|
|
struct static_extra_info *extra;
|
2018-02-08 11:37:23 +01:00
|
|
|
|
|
|
|
if (hicon && !get_icon_size( hicon, &size ))
|
|
|
|
{
|
|
|
|
WARN("hicon != 0, but invalid\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2020-02-10 09:31:39 +01:00
|
|
|
|
|
|
|
extra = get_extra_ptr( hwnd, TRUE );
|
|
|
|
if (!extra) return 0;
|
|
|
|
|
|
|
|
prevIcon = extra->image.hicon;
|
|
|
|
extra->image.hicon = hicon;
|
2018-02-08 11:37:23 +01:00
|
|
|
if (hicon && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
|
|
|
|
{
|
|
|
|
/* Windows currently doesn't implement SS_RIGHTJUST */
|
|
|
|
/*
|
|
|
|
if ((style & SS_RIGHTJUST) != 0)
|
|
|
|
{
|
|
|
|
RECT wr;
|
|
|
|
GetWindowRect(hwnd, &wr);
|
|
|
|
SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
|
|
|
|
info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
|
|
|
|
}
|
|
|
|
else */
|
|
|
|
{
|
|
|
|
SetWindowPos( hwnd, 0, 0, 0, size.cx, size.cy, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return prevIcon;
|
|
|
|
}
|
|
|
|
|
2020-02-10 09:31:41 +01:00
|
|
|
static HBITMAP create_alpha_bitmap( HBITMAP hbitmap )
|
|
|
|
{
|
|
|
|
BITMAP bm;
|
|
|
|
HBITMAP alpha;
|
|
|
|
BITMAPINFO info;
|
|
|
|
HDC hdc;
|
|
|
|
void *bits;
|
|
|
|
DWORD i;
|
|
|
|
BYTE *ptr;
|
|
|
|
BOOL has_alpha = FALSE;
|
|
|
|
|
|
|
|
GetObjectW( hbitmap, sizeof(bm), &bm );
|
|
|
|
if (bm.bmBitsPixel != 32) return 0;
|
|
|
|
|
|
|
|
if (!(hdc = CreateCompatibleDC( 0 ))) return 0;
|
|
|
|
|
|
|
|
info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
info.bmiHeader.biWidth = bm.bmWidth;
|
|
|
|
info.bmiHeader.biHeight = -bm.bmHeight;
|
|
|
|
info.bmiHeader.biPlanes = 1;
|
|
|
|
info.bmiHeader.biBitCount = 32;
|
|
|
|
info.bmiHeader.biCompression = BI_RGB;
|
|
|
|
info.bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4;
|
|
|
|
info.bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
info.bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
info.bmiHeader.biClrUsed = 0;
|
|
|
|
info.bmiHeader.biClrImportant = 0;
|
|
|
|
if ((alpha = CreateDIBSection( hdc, &info, DIB_RGB_COLORS, &bits, NULL, 0 )))
|
|
|
|
{
|
|
|
|
GetDIBits( hdc, hbitmap, 0, bm.bmHeight, bits, &info, DIB_RGB_COLORS );
|
|
|
|
|
|
|
|
for (i = 0, ptr = bits; i < bm.bmWidth * bm.bmHeight; i++, ptr += 4)
|
|
|
|
if ((has_alpha = (ptr[3] != 0))) break;
|
|
|
|
|
|
|
|
if (!has_alpha)
|
|
|
|
{
|
|
|
|
DeleteObject( alpha );
|
|
|
|
alpha = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteDC( hdc );
|
|
|
|
|
|
|
|
return alpha;
|
|
|
|
}
|
|
|
|
|
2018-02-08 11:37:23 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* STATIC_SetBitmap
|
|
|
|
*
|
|
|
|
* Set the bitmap for an SS_BITMAP control.
|
|
|
|
*/
|
|
|
|
static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
|
|
|
|
{
|
2020-02-10 09:31:41 +01:00
|
|
|
HBITMAP hOldBitmap, alpha;
|
2020-02-10 09:31:39 +01:00
|
|
|
struct static_extra_info *extra;
|
2018-02-08 11:37:23 +01:00
|
|
|
|
|
|
|
if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP)
|
|
|
|
{
|
|
|
|
WARN("hBitmap != 0, but it's not a bitmap\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2020-02-10 09:31:39 +01:00
|
|
|
|
|
|
|
extra = get_extra_ptr( hwnd, TRUE );
|
|
|
|
if (!extra) return 0;
|
|
|
|
|
|
|
|
hOldBitmap = extra->image.hbitmap;
|
|
|
|
extra->image.hbitmap = hBitmap;
|
2020-02-10 09:31:41 +01:00
|
|
|
extra->image_has_alpha = FALSE;
|
|
|
|
|
|
|
|
if (hBitmap)
|
|
|
|
{
|
|
|
|
alpha = create_alpha_bitmap( hBitmap );
|
|
|
|
if (alpha)
|
|
|
|
{
|
|
|
|
extra->image.hbitmap = alpha;
|
|
|
|
extra->image_has_alpha = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-08 11:37:23 +01:00
|
|
|
if (hBitmap && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
|
|
|
|
{
|
|
|
|
BITMAP bm;
|
|
|
|
GetObjectW(hBitmap, sizeof(bm), &bm);
|
2020-02-10 09:31:41 +01:00
|
|
|
|
2018-02-08 11:37:23 +01:00
|
|
|
/* Windows currently doesn't implement SS_RIGHTJUST */
|
|
|
|
/*
|
|
|
|
if ((style & SS_RIGHTJUST) != 0)
|
|
|
|
{
|
|
|
|
RECT wr;
|
|
|
|
GetWindowRect(hwnd, &wr);
|
|
|
|
SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
|
|
|
|
bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
|
|
|
|
}
|
|
|
|
else */
|
|
|
|
{
|
|
|
|
SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
|
|
|
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hOldBitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* STATIC_SetEnhMetaFile
|
|
|
|
*
|
|
|
|
* Set the enhanced metafile for an SS_ENHMETAFILE control.
|
|
|
|
*/
|
|
|
|
static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
|
|
|
|
{
|
2020-02-10 09:31:39 +01:00
|
|
|
HENHMETAFILE old_hemf;
|
|
|
|
struct static_extra_info *extra;
|
|
|
|
|
2018-02-08 11:37:23 +01:00
|
|
|
if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE)
|
|
|
|
{
|
|
|
|
WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2020-02-10 09:31:39 +01:00
|
|
|
|
|
|
|
extra = get_extra_ptr( hwnd, TRUE );
|
|
|
|
if (!extra) return 0;
|
|
|
|
|
|
|
|
old_hemf = extra->image.hemf;
|
|
|
|
extra->image.hemf = hEnhMetaFile;
|
|
|
|
|
|
|
|
return old_hemf;
|
2018-02-08 11:37:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* STATIC_GetImage
|
|
|
|
*
|
|
|
|
* Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
|
|
|
|
* SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
|
|
|
|
*/
|
|
|
|
static HANDLE STATIC_GetImage( HWND hwnd, WPARAM wParam, DWORD style )
|
|
|
|
{
|
2020-02-10 09:31:39 +01:00
|
|
|
struct static_extra_info *extra;
|
|
|
|
|
2018-02-08 11:37:23 +01:00
|
|
|
switch (style & SS_TYPEMASK)
|
|
|
|
{
|
|
|
|
case SS_ICON:
|
|
|
|
if ((wParam != IMAGE_ICON) &&
|
|
|
|
(wParam != IMAGE_CURSOR)) return NULL;
|
|
|
|
break;
|
|
|
|
case SS_BITMAP:
|
|
|
|
if (wParam != IMAGE_BITMAP) return NULL;
|
|
|
|
break;
|
|
|
|
case SS_ENHMETAFILE:
|
|
|
|
if (wParam != IMAGE_ENHMETAFILE) return NULL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-02-10 09:31:39 +01:00
|
|
|
|
|
|
|
extra = get_extra_ptr( hwnd, FALSE );
|
|
|
|
return extra ? extra->image.hbitmap : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STATIC_SetFont( HWND hwnd, HFONT hfont )
|
|
|
|
{
|
|
|
|
struct static_extra_info *extra = get_extra_ptr( hwnd, TRUE );
|
|
|
|
if (extra)
|
|
|
|
extra->hfont = hfont;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HFONT STATIC_GetFont( HWND hwnd )
|
|
|
|
{
|
|
|
|
struct static_extra_info *extra = get_extra_ptr( hwnd, FALSE );
|
|
|
|
return extra ? extra->hfont : 0;
|
2018-02-08 11:37:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* STATIC_LoadIconW
|
|
|
|
*
|
|
|
|
* Load the icon for an SS_ICON control.
|
|
|
|
*/
|
|
|
|
static HICON STATIC_LoadIconW( HINSTANCE hInstance, LPCWSTR name, DWORD style )
|
|
|
|
{
|
|
|
|
HICON hicon = 0;
|
|
|
|
|
|
|
|
if (hInstance && ((ULONG_PTR)hInstance >> 16))
|
|
|
|
{
|
|
|
|
if ((style & SS_REALSIZEIMAGE) != 0)
|
|
|
|
hicon = LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hicon = LoadIconW( hInstance, name );
|
|
|
|
if (!hicon) hicon = LoadCursorW( hInstance, name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!hicon) hicon = LoadIconW( 0, name );
|
|
|
|
/* Windows doesn't try to load a standard cursor,
|
|
|
|
probably because most IDs for standard cursors conflict
|
|
|
|
with the IDs for standard icons anyway */
|
|
|
|
return hicon;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* STATIC_TryPaintFcn
|
|
|
|
*
|
|
|
|
* Try to immediately paint the control.
|
|
|
|
*/
|
|
|
|
static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
|
|
|
|
{
|
|
|
|
LONG style = full_style & SS_TYPEMASK;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
GetClientRect( hwnd, &rc );
|
|
|
|
if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style])
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HRGN hrgn;
|
|
|
|
|
|
|
|
hdc = GetDC( hwnd );
|
|
|
|
hrgn = set_control_clipping( hdc, &rc );
|
|
|
|
(staticPaintFunc[style])( hwnd, hdc, full_style );
|
|
|
|
SelectClipRgn( hdc, hrgn );
|
|
|
|
if (hrgn) DeleteObject( hrgn );
|
|
|
|
ReleaseDC( hwnd, hdc );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
|
|
|
|
{
|
|
|
|
HBRUSH hBrush;
|
|
|
|
HWND parent = GetParent(hwnd);
|
|
|
|
|
|
|
|
if (!parent) parent = hwnd;
|
|
|
|
hBrush = (HBRUSH) SendMessageW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
|
|
|
|
if (!hBrush) /* did the app forget to call DefWindowProc ? */
|
|
|
|
{
|
|
|
|
/* FIXME: DefWindowProc should return different colors if a
|
|
|
|
manifest is present */
|
|
|
|
hBrush = (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd);
|
|
|
|
}
|
|
|
|
return hBrush;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* hasTextStyle
|
|
|
|
*
|
|
|
|
* Tests if the control displays text.
|
|
|
|
*/
|
|
|
|
static BOOL hasTextStyle( DWORD style )
|
|
|
|
{
|
|
|
|
switch (style & SS_TYPEMASK)
|
|
|
|
{
|
|
|
|
case SS_SIMPLE:
|
|
|
|
case SS_LEFT:
|
|
|
|
case SS_LEFTNOWORDWRAP:
|
|
|
|
case SS_CENTER:
|
|
|
|
case SS_RIGHT:
|
|
|
|
case SS_OWNERDRAW:
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK STATIC_WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
LRESULT lResult = 0;
|
|
|
|
LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
LONG style = full_style & SS_TYPEMASK;
|
|
|
|
|
|
|
|
if (!IsWindow( hwnd )) return 0;
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
2022-01-24 08:47:33 +01:00
|
|
|
{
|
|
|
|
HWND parent;
|
|
|
|
|
2018-02-08 11:37:23 +01:00
|
|
|
if (style < 0L || style > SS_TYPEMASK)
|
|
|
|
{
|
|
|
|
ERR("Unknown style 0x%02x\n", style );
|
|
|
|
return -1;
|
|
|
|
}
|
2022-01-24 08:47:33 +01:00
|
|
|
|
|
|
|
parent = GetParent( hwnd );
|
|
|
|
if (parent)
|
|
|
|
EnableThemeDialogTexture( parent, ETDT_ENABLE );
|
2018-02-08 11:37:23 +01:00
|
|
|
break;
|
2022-01-24 08:47:33 +01:00
|
|
|
}
|
2018-02-08 11:37:23 +01:00
|
|
|
|
|
|
|
case WM_NCDESTROY:
|
|
|
|
if (style == SS_ICON)
|
|
|
|
{
|
2020-02-10 09:31:39 +01:00
|
|
|
struct static_extra_info *extra = get_extra_ptr( hwnd, FALSE );
|
2020-02-10 09:31:41 +01:00
|
|
|
if (extra)
|
|
|
|
{
|
|
|
|
if (extra->image_has_alpha)
|
|
|
|
DeleteObject( extra->image.hbitmap );
|
|
|
|
heap_free( extra );
|
|
|
|
}
|
2018-02-08 11:37:23 +01:00
|
|
|
/*
|
|
|
|
* FIXME
|
|
|
|
* DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
|
|
|
|
*
|
|
|
|
* We don't want to do this yet because DestroyIcon32 is broken. If the icon
|
|
|
|
* had already been loaded by the application the last thing we want to do is
|
|
|
|
* GlobalFree16 the handle.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
|
|
|
|
|
|
|
case WM_ERASEBKGND:
|
|
|
|
/* do all painting in WM_PAINT like Windows does */
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case WM_PRINTCLIENT:
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
RECT rect;
|
|
|
|
HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
|
|
|
|
GetClientRect( hwnd, &rect );
|
|
|
|
if (staticPaintFunc[style])
|
|
|
|
{
|
|
|
|
HRGN hrgn = set_control_clipping( hdc, &rect );
|
|
|
|
(staticPaintFunc[style])( hwnd, hdc, full_style );
|
|
|
|
SelectClipRgn( hdc, hrgn );
|
|
|
|
if (hrgn) DeleteObject( hrgn );
|
|
|
|
}
|
|
|
|
if (!wParam) EndPaint(hwnd, &ps);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_ENABLE:
|
|
|
|
STATIC_TryPaintFcn( hwnd, full_style );
|
|
|
|
if (full_style & SS_NOTIFY)
|
|
|
|
{
|
|
|
|
if (wParam)
|
|
|
|
SendMessageW( GetParent(hwnd), WM_COMMAND,
|
|
|
|
MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_ENABLE ), (LPARAM)hwnd);
|
|
|
|
else
|
|
|
|
SendMessageW( GetParent(hwnd), WM_COMMAND,
|
|
|
|
MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DISABLE ), (LPARAM)hwnd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SYSCOLORCHANGE:
|
2018-02-11 17:19:56 +01:00
|
|
|
COMCTL32_RefreshSysColors();
|
2018-02-08 11:37:23 +01:00
|
|
|
STATIC_TryPaintFcn( hwnd, full_style );
|
|
|
|
break;
|
|
|
|
|
2021-04-27 05:35:01 +02:00
|
|
|
case WM_THEMECHANGED:
|
|
|
|
InvalidateRect( hwnd, 0, TRUE );
|
|
|
|
break;
|
|
|
|
|
2018-02-08 11:37:23 +01:00
|
|
|
case WM_NCCREATE:
|
|
|
|
{
|
|
|
|
CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
|
|
|
|
|
|
|
|
if (full_style & SS_SUNKEN)
|
|
|
|
SetWindowLongW( hwnd, GWL_EXSTYLE,
|
|
|
|
GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
|
|
|
|
|
|
|
|
switch (style)
|
|
|
|
{
|
|
|
|
case SS_ICON:
|
|
|
|
{
|
|
|
|
HICON hIcon;
|
|
|
|
|
|
|
|
hIcon = STATIC_LoadIconW(cs->hInstance, cs->lpszName, full_style);
|
|
|
|
STATIC_SetIcon(hwnd, hIcon, full_style);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SS_BITMAP:
|
|
|
|
if ((ULONG_PTR)cs->hInstance >> 16)
|
|
|
|
{
|
|
|
|
HBITMAP hBitmap;
|
|
|
|
hBitmap = LoadBitmapW(cs->hInstance, cs->lpszName);
|
|
|
|
STATIC_SetBitmap(hwnd, hBitmap, full_style);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
|
|
|
|
the enhanced metafile that was specified as the window text. */
|
|
|
|
}
|
|
|
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
|
|
|
|
|
|
|
case WM_SETTEXT:
|
|
|
|
if (hasTextStyle( full_style ))
|
|
|
|
{
|
|
|
|
lResult = DefWindowProcW( hwnd, uMsg, wParam, lParam );
|
|
|
|
STATIC_TryPaintFcn( hwnd, full_style );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SETFONT:
|
|
|
|
if (hasTextStyle( full_style ))
|
|
|
|
{
|
2020-02-10 09:31:39 +01:00
|
|
|
STATIC_SetFont( hwnd, (HFONT)wParam );
|
2018-02-08 11:37:23 +01:00
|
|
|
if (LOWORD(lParam))
|
|
|
|
RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_GETFONT:
|
2020-02-10 09:31:39 +01:00
|
|
|
return (LRESULT)STATIC_GetFont( hwnd );
|
2018-02-08 11:37:23 +01:00
|
|
|
|
|
|
|
case WM_NCHITTEST:
|
|
|
|
if (full_style & SS_NOTIFY)
|
|
|
|
return HTCLIENT;
|
|
|
|
else
|
|
|
|
return HTTRANSPARENT;
|
|
|
|
|
|
|
|
case WM_GETDLGCODE:
|
|
|
|
return DLGC_STATIC;
|
|
|
|
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_NCLBUTTONDOWN:
|
|
|
|
if (full_style & SS_NOTIFY)
|
|
|
|
SendMessageW( GetParent(hwnd), WM_COMMAND,
|
|
|
|
MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_CLICKED ), (LPARAM)hwnd);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
case WM_NCLBUTTONDBLCLK:
|
|
|
|
if (full_style & SS_NOTIFY)
|
|
|
|
SendMessageW( GetParent(hwnd), WM_COMMAND,
|
|
|
|
MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DBLCLK ), (LPARAM)hwnd);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case STM_GETIMAGE:
|
|
|
|
return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style );
|
|
|
|
|
|
|
|
case STM_GETICON:
|
|
|
|
return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style );
|
|
|
|
|
|
|
|
case STM_SETIMAGE:
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case IMAGE_BITMAP:
|
2021-08-18 11:36:30 +02:00
|
|
|
if (style != SS_BITMAP) return 0;
|
2018-02-08 11:37:23 +01:00
|
|
|
lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
|
|
|
|
break;
|
|
|
|
case IMAGE_ENHMETAFILE:
|
2021-08-18 11:36:30 +02:00
|
|
|
if (style != SS_ENHMETAFILE) return 0;
|
2018-02-08 11:37:23 +01:00
|
|
|
lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
|
|
|
|
break;
|
|
|
|
case IMAGE_ICON:
|
|
|
|
case IMAGE_CURSOR:
|
2021-08-18 11:36:30 +02:00
|
|
|
if (style != SS_ICON) return 0;
|
2018-02-08 11:37:23 +01:00
|
|
|
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
STATIC_TryPaintFcn( hwnd, full_style );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STM_SETICON:
|
2021-08-18 11:36:30 +02:00
|
|
|
if (style != SS_ICON) return 0;
|
2018-02-08 11:37:23 +01:00
|
|
|
lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
|
|
|
|
STATIC_TryPaintFcn( hwnd, full_style );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
return lResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
|
|
|
|
{
|
|
|
|
DRAWITEMSTRUCT dis;
|
|
|
|
HFONT font, oldFont = NULL;
|
|
|
|
UINT id = (UINT)GetWindowLongPtrW( hwnd, GWLP_ID );
|
|
|
|
|
|
|
|
dis.CtlType = ODT_STATIC;
|
|
|
|
dis.CtlID = id;
|
|
|
|
dis.itemID = 0;
|
|
|
|
dis.itemAction = ODA_DRAWENTIRE;
|
|
|
|
dis.itemState = IsWindowEnabled(hwnd) ? 0 : ODS_DISABLED;
|
|
|
|
dis.hwndItem = hwnd;
|
|
|
|
dis.hDC = hdc;
|
|
|
|
dis.itemData = 0;
|
|
|
|
GetClientRect( hwnd, &dis.rcItem );
|
|
|
|
|
2020-02-10 09:31:39 +01:00
|
|
|
font = STATIC_GetFont( hwnd );
|
2018-02-08 11:37:23 +01:00
|
|
|
if (font) oldFont = SelectObject( hdc, font );
|
|
|
|
SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
|
|
|
|
SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
|
|
|
|
if (font) SelectObject( hdc, oldFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
HBRUSH hBrush;
|
|
|
|
HFONT hFont, hOldFont = NULL;
|
|
|
|
UINT format;
|
|
|
|
INT len, buf_size;
|
|
|
|
WCHAR *text;
|
|
|
|
|
|
|
|
GetClientRect( hwnd, &rc);
|
|
|
|
|
|
|
|
switch (style & SS_TYPEMASK)
|
|
|
|
{
|
|
|
|
case SS_LEFT:
|
|
|
|
format = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_CENTER:
|
|
|
|
format = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_RIGHT:
|
|
|
|
format = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_SIMPLE:
|
|
|
|
format = DT_LEFT | DT_SINGLELINE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SS_LEFTNOWORDWRAP:
|
|
|
|
format = DT_LEFT | DT_EXPANDTABS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_RIGHT)
|
|
|
|
format = DT_RIGHT | (format & ~(DT_LEFT | DT_CENTER));
|
|
|
|
|
|
|
|
if (style & SS_NOPREFIX)
|
|
|
|
format |= DT_NOPREFIX;
|
|
|
|
|
|
|
|
if ((style & SS_TYPEMASK) != SS_SIMPLE)
|
|
|
|
{
|
|
|
|
if (style & SS_CENTERIMAGE)
|
|
|
|
format |= DT_SINGLELINE | DT_VCENTER;
|
|
|
|
if (style & SS_EDITCONTROL)
|
|
|
|
format |= DT_EDITCONTROL;
|
|
|
|
if (style & SS_ENDELLIPSIS)
|
|
|
|
format |= DT_SINGLELINE | DT_END_ELLIPSIS;
|
|
|
|
if (style & SS_PATHELLIPSIS)
|
|
|
|
format |= DT_SINGLELINE | DT_PATH_ELLIPSIS;
|
|
|
|
if (style & SS_WORDELLIPSIS)
|
|
|
|
format |= DT_SINGLELINE | DT_WORD_ELLIPSIS;
|
|
|
|
}
|
|
|
|
|
2020-02-10 09:31:39 +01:00
|
|
|
if ((hFont = STATIC_GetFont( hwnd )))
|
2018-02-08 11:37:23 +01:00
|
|
|
hOldFont = SelectObject( hdc, hFont );
|
|
|
|
|
|
|
|
/* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
|
|
|
|
brush is not used */
|
|
|
|
hBrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
|
|
|
|
|
|
|
|
if ((style & SS_TYPEMASK) != SS_SIMPLE)
|
|
|
|
{
|
|
|
|
FillRect( hdc, &rc, hBrush );
|
|
|
|
if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
|
|
|
|
}
|
|
|
|
|
|
|
|
buf_size = 256;
|
|
|
|
if (!(text = HeapAlloc( GetProcessHeap(), 0, buf_size * sizeof(WCHAR) )))
|
|
|
|
goto no_TextOut;
|
|
|
|
|
|
|
|
while ((len = InternalGetWindowText( hwnd, text, buf_size )) == buf_size - 1)
|
|
|
|
{
|
|
|
|
buf_size *= 2;
|
|
|
|
if (!(text = HeapReAlloc( GetProcessHeap(), 0, text, buf_size * sizeof(WCHAR) )))
|
|
|
|
goto no_TextOut;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!len) goto no_TextOut;
|
|
|
|
|
|
|
|
if (((style & SS_TYPEMASK) == SS_SIMPLE) && (style & SS_NOPREFIX))
|
|
|
|
{
|
|
|
|
/* Windows uses the faster ExtTextOut() to draw the text and
|
|
|
|
to paint the whole client rectangle with the text background
|
|
|
|
color. Reference: "Static Controls" by Kyle Marsh, 1992 */
|
|
|
|
ExtTextOutW( hdc, rc.left, rc.top, ETO_CLIPPED | ETO_OPAQUE,
|
|
|
|
&rc, text, len, NULL );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawTextW( hdc, text, -1, &rc, format );
|
|
|
|
}
|
|
|
|
|
|
|
|
no_TextOut:
|
|
|
|
HeapFree( GetProcessHeap(), 0, text );
|
|
|
|
|
|
|
|
if (hFont)
|
|
|
|
SelectObject( hdc, hOldFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
HBRUSH hBrush;
|
|
|
|
|
|
|
|
GetClientRect( hwnd, &rc);
|
|
|
|
|
|
|
|
/* FIXME: send WM_CTLCOLORSTATIC */
|
|
|
|
switch (style & SS_TYPEMASK)
|
|
|
|
{
|
|
|
|
case SS_BLACKRECT:
|
2018-02-11 17:19:56 +01:00
|
|
|
hBrush = CreateSolidBrush(comctl32_color.clr3dDkShadow);
|
2018-02-08 11:37:23 +01:00
|
|
|
FillRect( hdc, &rc, hBrush );
|
|
|
|
break;
|
|
|
|
case SS_GRAYRECT:
|
2018-02-11 17:19:56 +01:00
|
|
|
hBrush = CreateSolidBrush(comctl32_color.clr3dShadow);
|
2018-02-08 11:37:23 +01:00
|
|
|
FillRect( hdc, &rc, hBrush );
|
|
|
|
break;
|
|
|
|
case SS_WHITERECT:
|
2018-02-11 17:19:56 +01:00
|
|
|
hBrush = CreateSolidBrush(comctl32_color.clr3dHilight);
|
2018-02-08 11:37:23 +01:00
|
|
|
FillRect( hdc, &rc, hBrush );
|
|
|
|
break;
|
|
|
|
case SS_BLACKFRAME:
|
2018-02-11 17:19:56 +01:00
|
|
|
hBrush = CreateSolidBrush(comctl32_color.clr3dDkShadow);
|
2018-02-08 11:37:23 +01:00
|
|
|
FrameRect( hdc, &rc, hBrush );
|
|
|
|
break;
|
|
|
|
case SS_GRAYFRAME:
|
2018-02-11 17:19:56 +01:00
|
|
|
hBrush = CreateSolidBrush(comctl32_color.clr3dShadow);
|
2018-02-08 11:37:23 +01:00
|
|
|
FrameRect( hdc, &rc, hBrush );
|
|
|
|
break;
|
|
|
|
case SS_WHITEFRAME:
|
2018-02-11 17:19:56 +01:00
|
|
|
hBrush = CreateSolidBrush(comctl32_color.clr3dHilight);
|
2018-02-08 11:37:23 +01:00
|
|
|
FrameRect( hdc, &rc, hBrush );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DeleteObject( hBrush );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
|
|
|
|
{
|
|
|
|
RECT rc, iconRect;
|
|
|
|
HBRUSH hbrush;
|
|
|
|
HICON hIcon;
|
|
|
|
SIZE size;
|
|
|
|
|
|
|
|
GetClientRect( hwnd, &rc );
|
|
|
|
hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
|
2020-02-10 09:31:39 +01:00
|
|
|
hIcon = STATIC_GetImage( hwnd, IMAGE_ICON, style );
|
2018-02-08 11:37:23 +01:00
|
|
|
if (!hIcon || !get_icon_size( hIcon, &size ))
|
|
|
|
{
|
|
|
|
FillRect(hdc, &rc, hbrush);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (style & SS_CENTERIMAGE)
|
|
|
|
{
|
|
|
|
iconRect.left = (rc.right - rc.left) / 2 - size.cx / 2;
|
|
|
|
iconRect.top = (rc.bottom - rc.top) / 2 - size.cy / 2;
|
|
|
|
iconRect.right = iconRect.left + size.cx;
|
|
|
|
iconRect.bottom = iconRect.top + size.cy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
iconRect = rc;
|
|
|
|
FillRect( hdc, &rc, hbrush );
|
|
|
|
DrawIconEx( hdc, iconRect.left, iconRect.top, hIcon, iconRect.right - iconRect.left,
|
|
|
|
iconRect.bottom - iconRect.top, 0, NULL, DI_NORMAL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
|
|
|
|
{
|
|
|
|
HDC hMemDC;
|
|
|
|
HBITMAP hBitmap, oldbitmap;
|
|
|
|
HBRUSH hbrush;
|
|
|
|
|
|
|
|
hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
|
|
|
|
|
2020-02-10 09:31:39 +01:00
|
|
|
if ((hBitmap = STATIC_GetImage( hwnd, IMAGE_BITMAP, style ))
|
2018-02-08 11:37:23 +01:00
|
|
|
&& (GetObjectType(hBitmap) == OBJ_BITMAP)
|
|
|
|
&& (hMemDC = CreateCompatibleDC( hdc )))
|
|
|
|
{
|
|
|
|
BITMAP bm;
|
|
|
|
RECT rcClient;
|
|
|
|
LOGBRUSH brush;
|
2020-02-10 09:31:41 +01:00
|
|
|
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
|
|
|
|
struct static_extra_info *extra = get_extra_ptr( hwnd, FALSE );
|
2018-02-08 11:37:23 +01:00
|
|
|
|
|
|
|
GetObjectW(hBitmap, sizeof(bm), &bm);
|
|
|
|
oldbitmap = SelectObject(hMemDC, hBitmap);
|
|
|
|
|
|
|
|
/* Set the background color for monochrome bitmaps
|
|
|
|
to the color of the background brush */
|
|
|
|
if (GetObjectW( hbrush, sizeof(brush), &brush ))
|
|
|
|
{
|
|
|
|
if (brush.lbStyle == BS_SOLID)
|
|
|
|
SetBkColor(hdc, brush.lbColor);
|
|
|
|
}
|
|
|
|
GetClientRect(hwnd, &rcClient);
|
|
|
|
if (style & SS_CENTERIMAGE)
|
|
|
|
{
|
|
|
|
FillRect( hdc, &rcClient, hbrush );
|
|
|
|
rcClient.left = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
|
|
|
|
rcClient.top = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
|
|
|
|
rcClient.right = rcClient.left + bm.bmWidth;
|
|
|
|
rcClient.bottom = rcClient.top + bm.bmHeight;
|
|
|
|
}
|
2020-02-10 09:31:41 +01:00
|
|
|
|
|
|
|
if (extra->image_has_alpha)
|
|
|
|
GdiAlphaBlend(hdc, rcClient.left, rcClient.top, rcClient.right - rcClient.left,
|
|
|
|
rcClient.bottom - rcClient.top, hMemDC,
|
|
|
|
0, 0, bm.bmWidth, bm.bmHeight, blend);
|
|
|
|
else
|
|
|
|
StretchBlt(hdc, rcClient.left, rcClient.top, rcClient.right - rcClient.left,
|
2018-02-08 11:37:23 +01:00
|
|
|
rcClient.bottom - rcClient.top, hMemDC,
|
|
|
|
0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
|
|
|
|
SelectObject(hMemDC, oldbitmap);
|
|
|
|
DeleteDC(hMemDC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
|
|
|
|
{
|
|
|
|
HENHMETAFILE hEnhMetaFile;
|
|
|
|
RECT rc;
|
|
|
|
HBRUSH hbrush;
|
|
|
|
|
|
|
|
GetClientRect(hwnd, &rc);
|
|
|
|
hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
|
|
|
|
FillRect(hdc, &rc, hbrush);
|
2020-02-10 09:31:39 +01:00
|
|
|
if ((hEnhMetaFile = STATIC_GetImage( hwnd, IMAGE_ENHMETAFILE, style )))
|
2018-02-08 11:37:23 +01:00
|
|
|
{
|
|
|
|
/* The control's current font is not selected into the
|
|
|
|
device context! */
|
|
|
|
if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
|
|
|
|
PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
/* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
|
|
|
|
GetClientRect( hwnd, &rc );
|
|
|
|
switch (style & SS_TYPEMASK)
|
|
|
|
{
|
|
|
|
case SS_ETCHEDHORZ:
|
|
|
|
DrawEdge(hdc, &rc, EDGE_ETCHED, BF_TOP | BF_BOTTOM);
|
|
|
|
break;
|
|
|
|
case SS_ETCHEDVERT:
|
|
|
|
DrawEdge(hdc, &rc, EDGE_ETCHED, BF_LEFT | BF_RIGHT);
|
|
|
|
break;
|
|
|
|
case SS_ETCHEDFRAME:
|
|
|
|
DrawEdge(hdc, &rc, EDGE_ETCHED, BF_RECT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void STATIC_Register(void)
|
|
|
|
{
|
|
|
|
WNDCLASSW wndClass;
|
|
|
|
|
|
|
|
memset(&wndClass, 0, sizeof(wndClass));
|
|
|
|
wndClass.style = CS_DBLCLKS | CS_PARENTDC | CS_GLOBALCLASS;
|
|
|
|
wndClass.lpfnWndProc = STATIC_WindowProc;
|
|
|
|
wndClass.cbClsExtra = 0;
|
2020-02-10 09:31:39 +01:00
|
|
|
wndClass.cbWndExtra = sizeof(struct static_extra_info *);
|
2018-02-08 11:37:23 +01:00
|
|
|
wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
|
|
|
|
wndClass.hbrBackground = NULL;
|
|
|
|
wndClass.lpszClassName = WC_STATICW;
|
|
|
|
RegisterClassW(&wndClass);
|
|
|
|
}
|