Jacek Caban : win32u: Move EnableWindow implementation from user32.
Alexandre Julliard
julliard at winehq.org
Thu Apr 14 16:50:34 CDT 2022
Module: wine
Branch: master
Commit: 8b6a4584b80477f5dc43d71fe2dd16f7b1a135de
URL: https://source.winehq.org/git/wine.git/?a=commit;h=8b6a4584b80477f5dc43d71fe2dd16f7b1a135de
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Apr 14 14:10:56 2022 +0200
win32u: Move EnableWindow implementation from user32.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/win.c | 30 +-----------------------------
dlls/win32u/window.c | 37 +++++++++++++++++++++++++++++++++++++
include/ntuser.h | 6 ++++++
3 files changed, 44 insertions(+), 29 deletions(-)
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index f5c22bfbadc..d44f058d256 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -869,35 +869,7 @@ HWND WINAPI GetDesktopWindow(void)
*/
BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
{
- BOOL retvalue;
-
- if (is_broadcast(hwnd))
- {
- SetLastError( ERROR_INVALID_PARAMETER );
- return FALSE;
- }
-
- TRACE("( %p, %d )\n", hwnd, enable);
-
- if (enable)
- {
- retvalue = (WIN_SetStyle( hwnd, 0, WS_DISABLED ) & WS_DISABLED) != 0;
- if (retvalue) SendMessageW( hwnd, WM_ENABLE, TRUE, 0 );
- }
- else
- {
- SendMessageW( hwnd, WM_CANCELMODE, 0, 0 );
-
- retvalue = (WIN_SetStyle( hwnd, WS_DISABLED, 0 ) & WS_DISABLED) != 0;
- if (!retvalue)
- {
- if (hwnd == GetFocus())
- NtUserSetFocus( 0 ); /* A disabled window can't have the focus */
-
- SendMessageW( hwnd, WM_ENABLE, FALSE, 0 );
- }
- }
- return retvalue;
+ return NtUserEnableWindow( hwnd, enable );
}
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c
index 6eb272ec227..eefc48a7d2d 100644
--- a/dlls/win32u/window.c
+++ b/dlls/win32u/window.c
@@ -807,6 +807,40 @@ BOOL is_window_unicode( HWND hwnd )
return ret;
}
+/* see EnableWindow */
+static BOOL enable_window( HWND hwnd, BOOL enable )
+{
+ BOOL ret;
+
+ if (is_broadcast(hwnd))
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+
+ TRACE( "( %p, %d )\n", hwnd, enable );
+
+ if (enable)
+ {
+ ret = (set_window_style( hwnd, 0, WS_DISABLED ) & WS_DISABLED) != 0;
+ if (ret) send_message( hwnd, WM_ENABLE, TRUE, 0 );
+ }
+ else
+ {
+ send_message( hwnd, WM_CANCELMODE, 0, 0 );
+
+ ret = (set_window_style( hwnd, WS_DISABLED, 0 ) & WS_DISABLED) != 0;
+ if (!ret)
+ {
+ if (hwnd == get_focus())
+ NtUserSetFocus( 0 ); /* A disabled window can't have the focus */
+
+ send_message( hwnd, WM_ENABLE, FALSE, 0 );
+ }
+ }
+ return ret;
+}
+
/* see IsWindowEnabled */
BOOL is_window_enabled( HWND hwnd )
{
@@ -5056,6 +5090,9 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code )
{
switch (code)
{
+ case NtUserCallHwndParam_EnableWindow:
+ return enable_window( hwnd, param );
+
case NtUserCallHwndParam_GetClassLongA:
return get_class_long( hwnd, param, TRUE );
diff --git a/include/ntuser.h b/include/ntuser.h
index 52bc6c12c32..d8228a521e2 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -832,6 +832,7 @@ static inline BOOL NtUserIsWindowVisible( HWND hwnd )
/* NtUserCallHwndParam codes, not compatible with Windows */
enum
{
+ NtUserCallHwndParam_EnableWindow,
NtUserCallHwndParam_GetClassLongA,
NtUserCallHwndParam_GetClassLongW,
NtUserCallHwndParam_GetClassLongPtrA,
@@ -863,6 +864,11 @@ enum
NtUserSpyGetMsgName,
};
+static inline BOOL NtUserEnableWindow( HWND hwnd, BOOL enable )
+{
+ return NtUserCallHwndParam( hwnd, enable, NtUserCallHwndParam_EnableWindow );
+}
+
static inline DWORD NtUserGetClassLongA( HWND hwnd, INT offset )
{
return NtUserCallHwndParam( hwnd, offset, NtUserCallHwndParam_GetClassLongA );
More information about the wine-cvs
mailing list