LRESULT CALLBACK
ButtonFilter(HWND hwnd, UINT wm, WPARAM wParam,
  LPARAM lParam)
/*****************************************************/
/* -- Display a stop sign icon on the face of a      */
/*    PushButton.                                    */
/*****************************************************/
    {
    static  BOOL    fDown;  /* Track button state. */
            LRESULT lw;     /* This routine's value. */

    /* Let button's real window proc do its work */
    /* first. */
    lw = CallWindowProc(lpfnButtonProc, hwnd, wm,
      wParam, lParam);

    switch (wm)
        {
    default:
        break;

    case BM_SETSTATE:
        /* Check to see if the state changed.  Do */
        /* nothing it not to avoid flicker. */
        if ((!wParam && !fDown) || (wParam && fDown))
            break;   /* No change. */

        fDown = wParam; /* Remember new state. */
        /* Fall through. */

    case WM_PAINT:
        {
        HDC     hdc;
        RECT    rect;
        int     dxDoubleBorder, dyDoubleBorder;
        int     dxOffset, dyOffset;
        int     dxIcon, dyIcon;

        /* Offset icon by 2 border thicknesses if */
        /* button is pushed down. */
        dxDoubleBorder =
          2 * GetSystemMetrics(SM_CXBORDER);
        dyDoubleBorder =
          2 * GetSystemMetrics(SM_CYBORDER);
        if (fDown)
            {
            dxOffset = dxDoubleBorder;
            dyOffset = dyDoubleBorder;
            }
        else
            {
            dxOffset = dyOffset = 0;
            }

        /* Paint the icon in the center of the */
        /* button plus offset. */
        hdc = GetDC(hwnd);
        GetClientRect(hwnd, &rect);
        dxIcon = GetSystemMetrics(SM_CXICON);

        dyIcon = GetSystemMetrics(SM_CYICON);
        rect.left = dxOffset +
          (rect.right - rect.left - dxIcon) / 2;
        rect.top = dyOffset +
          (rect.bottom - rect.top - dyIcon) / 2,
        DrawIcon(hdc, rect.left, rect.top,
          LoadIcon(NULL, (LPCSTR)IDI_HAND));
        if (GetFocus() == hwnd)
            {
            rect.right = rect.left + dxIcon;
            rect.bottom = rect.top + dyIcon;
            InflateRect(&rect, dxDoubleBorder,
              dyDoubleBorder);
            DrawFocusRect(hdc, &rect);
            }
        ReleaseDC(hwnd, hdc);
        }
        break;
        }

    return lw;
    }


