diff --git a/include/ctrl/ctrlhelper.h b/include/ctrl/ctrlhelper.h index 055c017f..2258ea59 100644 --- a/include/ctrl/ctrlhelper.h +++ b/include/ctrl/ctrlhelper.h @@ -188,8 +188,7 @@ MG_EXPORT void DestroyToolTipWin (HWND hwnd); * DWORD add_data) * \brief Send a notification message to the parent. * - * This function calls \a NotifyWindow to send a notification message - * to the parent. + * This function send a notification message to the parent. * * In the early version, the notification from a control will be sent to * its parent window within a MSG_COMMAND message. @@ -199,28 +198,13 @@ MG_EXPORT void DestroyToolTipWin (HWND hwnd); * \a SetNotificationCallback to receive and handle the notification from * its children in the procedure. * - * However, there was a bug in the old implementation. This function will - * check and call the notification callback procedure of the control itself - * instead of its parent. - * - * Therefore, since 5.0.0, we adjusted the implementation of this function - * as follow: - * - * - This function first checks and calls the notification callback procedure - * of the control itself if you had set. - * - If not, this function calls the new API \a NotifyWindow to send - * the notification to the parent of the control. - * - * The first step keeps the backward compatibility. And we recommend that - * you set the notification callback procedure for the parent in the - * future code. If you have set the notification callback procedure for - * the parent, MiniGUI will call the callback procedure eventually, - * instead of dispatching a MSG_COMMAND message to the window procedure of - * the parent. - * * Note that if the control has \a WS_EX_NOPARENTNOTIFY style, this function * will not notify the parent. * + * Note taht there was a mistake in the implementation. This function will + * check and call the notification callback procedure of the control itself + * instead of its parent. + * * Since 5.0.0, you can call NotifyWindow to notify any kind of window. * * \param hwnd The handle to current control window. diff --git a/src/control/ctrlmisc.c b/src/control/ctrlmisc.c index be4d2dfe..beef0512 100644 --- a/src/control/ctrlmisc.c +++ b/src/control/ctrlmisc.c @@ -240,19 +240,34 @@ void GUIAPI DisabledTextOutEx (HDC hdc, HWND hwnd, int x, int y, const char* szT /* Since 5.0.0, we use NotifyWindow to send the notification to the parent */ void GUIAPI NotifyParentEx (HWND hwnd, LINT id, int code, DWORD add_data) { +#if 1 NOTIFPROC notif_proc; + + if (GetWindowExStyle (hwnd) & WS_EX_NOPARENTNOTIFY) + return; + notif_proc = GetNotificationCallback (hwnd); - /* XXX: for backward compatibility */ + if (notif_proc) { + notif_proc (hwnd, id, code, add_data); + } + else { + SendNotifyMessage (GetParent (hwnd), + MSG_COMMAND, (WPARAM) MAKELONG (id, code), (LPARAM)hwnd); + } +#else + /* If we use NotifyWindow, the backward compatibility will be broken */ + NOTIFPROC notif_proc; + if (GetWindowExStyle (hwnd) & WS_EX_NOPARENTNOTIFY) + return; + + notif_proc = GetNotificationCallback (hwnd); if (notif_proc) { notif_proc (hwnd, id, code, add_data); } else { HWND parent; - if (GetWindowExStyle (hwnd) & WS_EX_NOPARENTNOTIFY) - return; - parent = GetParent (hwnd); if (parent == HWND_INVALID) { _WRN_PRINTF ("failed to get parent of window (%p)\n", hwnd); @@ -263,6 +278,7 @@ void GUIAPI NotifyParentEx (HWND hwnd, LINT id, int code, DWORD add_data) _WRN_PRINTF ("failed to notify parent (%p)\n", parent); } } +#endif } LRESULT GUIAPI DefaultPageProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)