[PATCH 2/8] comctl32/button: Implement NM_CUSTOMDRAW for Push Buttons

Nikolay Sivov nsivov at codeweavers.com
Mon Mar 4 12:19:27 CST 2019


On 3/4/19 7:25 PM, Gabriel Ivăncescu wrote:

> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=10531
> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
> ---
>
> This fixes WinXP calc perfectly, it seems it's how Windows does it (yes,
> the frame drawing is before pre-paint notification, otherwise it won't
> look correctly).
>
> Tests for all of them are at the end of the patch series, because they are
> done in an existing loop and it would be a nightmare otherwise to add todos
> only for some buttons but not others. The MSDN documentation is wrong and
> a mess for some CDRF_* values and many other info online gets it wrong,
> as the tests demonstrate.
>
>   dlls/comctl32/button.c | 105 +++++++++++++++++++++++++++++++----------
>   1 file changed, 79 insertions(+), 26 deletions(-)
>
> diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
> index 56a4730..25a46a4 100644
> --- a/dlls/comctl32/button.c
> +++ b/dlls/comctl32/button.c
> @@ -237,6 +237,30 @@ static inline WCHAR *get_button_text( const BUTTON_INFO *infoPtr )
>       return buffer;
>   }
>   
> +static void init_custom_draw(NMCUSTOMDRAW *nmcd, const BUTTON_INFO *info, HDC hDC, const RECT *rc)
> +{
> +    HWND hwnd = info->hwnd;
> +
> +    nmcd->hdr.hwndFrom = hwnd;
> +    nmcd->hdr.idFrom   = GetWindowLongPtrW(hwnd, GWLP_ID);
> +    nmcd->hdr.code     = NM_CUSTOMDRAW;
> +    nmcd->hdc          = hDC;
> +    nmcd->rc           = *rc;
> +    nmcd->dwDrawStage  = CDDS_PREERASE;
> +    nmcd->dwItemSpec   = 0;
> +    nmcd->lItemlParam  = 0;
> +    nmcd->uItemState   = !IsWindowEnabled(hwnd) ? CDIS_DISABLED : 0;
> +    if (info->state & BST_PUSHED)  nmcd->uItemState |= CDIS_SELECTED;
> +    if (info->state & BST_FOCUS)   nmcd->uItemState |= CDIS_FOCUS;
> +    if (info->state & BST_HOT)     nmcd->uItemState |= CDIS_HOT;
> +    if (info->state & BST_INDETERMINATE)
> +        nmcd->uItemState |= CDIS_INDETERMINATE;
> +
> +    /* Windows doesn't seem to send CDIS_CHECKED (it fails the tests) */
> +    /* CDIS_SHOWKEYBOARDCUES is misleading, as the meaning is reversed */
> +    /* FIXME: Handle it properly when we support keyboard cues? */
> +}
For consistency, could you make it 'infoPtr' and 'hdc'? Other minor 
simplifications, separate 'hwnd' variable seems unnecessary,
and uItemState condition could be flipped to get rid of negation.






More information about the wine-devel mailing list