Commit bd8026ca authored by Vitaly Lipatov's avatar Vitaly Lipatov Committed by Alexandre Julliard

Add BUTTON_NOTIFY_PARENT macro (as in edit.c).

Notify parent about WM_KILL/SETFOCUS events.
parent 255541a1
...@@ -48,9 +48,9 @@ ...@@ -48,9 +48,9 @@
* - BCN_HOTITEMCHANGE * - BCN_HOTITEMCHANGE
* - BN_DISABLE * - BN_DISABLE
* - BN_PUSHED/BN_HILITE * - BN_PUSHED/BN_HILITE
* - BN_KILLFOCUS * + BN_KILLFOCUS: is it OK?
* - BN_PAINT * - BN_PAINT
* - BN_SETFOCUS * + BN_SETFOCUS: is it OK?
* - BN_UNPUSHED/BN_UNHILITE * - BN_UNPUSHED/BN_UNHILITE
* - NM_CUSTOMDRAW * - NM_CUSTOMDRAW
* *
...@@ -74,6 +74,9 @@ ...@@ -74,6 +74,9 @@
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "controls.h" #include "controls.h"
#include "user_private.h" #include "user_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(button);
/* GetWindowLong offsets for window extra information */ /* GetWindowLong offsets for window extra information */
#define STATE_GWL_OFFSET 0 #define STATE_GWL_OFFSET 0
...@@ -93,6 +96,14 @@ ...@@ -93,6 +96,14 @@
#define BUTTON_UNKNOWN2 0x20 #define BUTTON_UNKNOWN2 0x20
#define BUTTON_UNKNOWN3 0x10 #define BUTTON_UNKNOWN3 0x10
#define BUTTON_NOTIFY_PARENT(hWnd, code) \
do { /* Notify parent which has created this button control */ \
TRACE("notification " #code " sent to hwnd=%p\n", GetParent(hWnd)); \
SendMessageW(GetParent(hWnd), WM_COMMAND, \
MAKEWPARAM(GetWindowLongPtrW((hWnd),GWLP_ID), (code)), \
(LPARAM)(hWnd)); \
} while(0)
static UINT BUTTON_CalcLabelRect( HWND hwnd, HDC hdc, RECT *rc ); static UINT BUTTON_CalcLabelRect( HWND hwnd, HDC hdc, RECT *rc );
static void PB_Paint( HWND hwnd, HDC hDC, UINT action ); static void PB_Paint( HWND hwnd, HDC hDC, UINT action );
static void CB_Paint( HWND hwnd, HDC hDC, UINT action ); static void CB_Paint( HWND hwnd, HDC hDC, UINT action );
...@@ -294,9 +305,7 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, ...@@ -294,9 +305,7 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
btn_type == BS_USERBUTTON || btn_type == BS_USERBUTTON ||
btn_type == BS_OWNERDRAW) btn_type == BS_OWNERDRAW)
{ {
SendMessageW( GetParent(hWnd), WM_COMMAND, BUTTON_NOTIFY_PARENT(hWnd, BN_DOUBLECLICKED);
MAKEWPARAM( GetWindowLongPtrW(hWnd,GWLP_ID), BN_DOUBLECLICKED ),
(LPARAM)hWnd);
break; break;
} }
/* fall through */ /* fall through */
...@@ -340,12 +349,12 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, ...@@ -340,12 +349,12 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
(state & BUTTON_3STATE) ? 0 : ((state & 3) + 1), 0 ); (state & BUTTON_3STATE) ? 0 : ((state & 3) + 1), 0 );
break; break;
} }
SendMessageW( GetParent(hWnd), WM_COMMAND, BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
MAKEWPARAM( GetWindowLongPtrW(hWnd,GWLP_ID), BN_CLICKED ), (LPARAM)hWnd);
} }
break; break;
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
TRACE("WM_CAPTURECHANGED %p\n", hWnd);
state = get_button_state( hWnd ); state = get_button_state( hWnd );
if (state & BUTTON_BTNPRESSED) if (state & BUTTON_BTNPRESSED)
{ {
...@@ -405,17 +414,24 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, ...@@ -405,17 +414,24 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
return (LRESULT)get_button_font( hWnd ); return (LRESULT)get_button_font( hWnd );
case WM_SETFOCUS: case WM_SETFOCUS:
TRACE("WM_SETFOCUS %p\n",hWnd);
set_button_state( hWnd, get_button_state(hWnd) | BUTTON_HASFOCUS ); set_button_state( hWnd, get_button_state(hWnd) | BUTTON_HASFOCUS );
paint_button( hWnd, btn_type, ODA_FOCUS ); paint_button( hWnd, btn_type, ODA_FOCUS );
if (style & BS_NOTIFY)
BUTTON_NOTIFY_PARENT(hWnd, BN_SETFOCUS);
break; break;
case WM_KILLFOCUS: case WM_KILLFOCUS:
TRACE("WM_KILLFOCUS %p\n",hWnd);
state = get_button_state( hWnd ); state = get_button_state( hWnd );
set_button_state( hWnd, state & ~BUTTON_HASFOCUS ); set_button_state( hWnd, state & ~BUTTON_HASFOCUS );
paint_button( hWnd, btn_type, ODA_FOCUS ); paint_button( hWnd, btn_type, ODA_FOCUS );
if ((state & BUTTON_BTNPRESSED) && GetCapture() == hWnd) if ((state & BUTTON_BTNPRESSED) && GetCapture() == hWnd)
ReleaseCapture(); ReleaseCapture();
if (style & BS_NOTIFY)
BUTTON_NOTIFY_PARENT(hWnd, BN_KILLFOCUS);
break; break;
case WM_SYSCOLORCHANGE: case WM_SYSCOLORCHANGE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment