Commit 3dc3709f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard
Browse files

win32u: Introduce NtUserGetDialogProc.

And use it in user32 instead of DEFDLG_GetDlgProc.
parent 1cd5702d
...@@ -29,27 +29,6 @@ ...@@ -29,27 +29,6 @@
#include "user_private.h" #include "user_private.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dialog);
/***********************************************************************
* DEFDLG_GetDlgProc
*/
static DLGPROC DEFDLG_GetDlgProc( HWND hwnd )
{
DLGPROC ret;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr) return 0;
if (wndPtr == WND_OTHER_PROCESS)
{
ERR( "cannot get dlg proc %p from other process\n", hwnd );
return 0;
}
ret = *(DLGPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC);
WIN_ReleasePtr( wndPtr );
return ret;
}
/*********************************************************************** /***********************************************************************
* DEFDLG_SetFocus * DEFDLG_SetFocus
...@@ -343,16 +322,14 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ) ...@@ -343,16 +322,14 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create )
static LRESULT USER_DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) static LRESULT USER_DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{ {
DIALOGINFO *dlgInfo; DIALOGINFO *dlgInfo;
DLGPROC dlgproc; LRESULT result;
LRESULT result = 0;
/* Perform DIALOGINFO initialization if not done */ /* Perform DIALOGINFO initialization if not done */
if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0; if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 );
if ((dlgproc = DEFDLG_GetDlgProc( hwnd ))) /* Call dialog procedure */ result = WINPROC_CallDlgProcA( hwnd, msg, wParam, lParam );
result = WINPROC_CallDlgProcA( dlgproc, hwnd, msg, wParam, lParam );
if (!result && IsWindow(hwnd)) if (!result && IsWindow(hwnd))
{ {
...@@ -397,16 +374,13 @@ static LRESULT USER_DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar ...@@ -397,16 +374,13 @@ static LRESULT USER_DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
static LRESULT USER_DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) static LRESULT USER_DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{ {
DIALOGINFO *dlgInfo; DIALOGINFO *dlgInfo;
DLGPROC dlgproc; LRESULT result;
LRESULT result = 0;
/* Perform DIALOGINFO initialization if not done */ /* Perform DIALOGINFO initialization if not done */
if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0; if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 );
result = WINPROC_CallDlgProcW( hwnd, msg, wParam, lParam );
if ((dlgproc = DEFDLG_GetDlgProc( hwnd ))) /* Call dialog procedure */
result = WINPROC_CallDlgProcW( dlgproc, hwnd, msg, wParam, lParam );
if (!result && IsWindow(hwnd)) if (!result && IsWindow(hwnd))
{ {
......
...@@ -1038,19 +1038,10 @@ static HWND DIALOG_FindMsgDestination( HWND hwndDlg ) ...@@ -1038,19 +1038,10 @@ static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
{ {
while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL) while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL)
{ {
WND *pParent;
HWND hParent = GetParent(hwndDlg); HWND hParent = GetParent(hwndDlg);
if (!hParent) break;
pParent = WIN_GetPtr(hParent); if (!hParent || !WIN_IsCurrentProcess( hParent )) break;
if (!pParent || pParent == WND_OTHER_PROCESS || pParent == WND_DESKTOP) break; if (!NtUserGetDialogInfo( hParent )) break;
if (!pParent->dlgInfo)
{
WIN_ReleasePtr(pParent);
break;
}
WIN_ReleasePtr(pParent);
hwndDlg = hParent; hwndDlg = hParent;
} }
...@@ -1183,14 +1174,8 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg ) ...@@ -1183,14 +1174,8 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
case VK_TAB: case VK_TAB:
if (!(dlgCode & DLGC_WANTTAB)) if (!(dlgCode & DLGC_WANTTAB))
{ {
BOOL fIsDialog = TRUE; BOOL fIsDialog = !WIN_IsCurrentProcess( hwndDlg ) ||
WND *pWnd = WIN_GetPtr( hwndDlg ); NtUserGetDialogInfo( hwndDlg ) != NULL;
if (pWnd && pWnd != WND_OTHER_PROCESS)
{
fIsDialog = (pWnd->dlgInfo != NULL);
WIN_ReleasePtr(pWnd);
}
/* I am not sure under which circumstances the TAB is handled /* I am not sure under which circumstances the TAB is handled
* each way. All I do know is that it does not always simply * each way. All I do know is that it does not always simply
......
...@@ -86,8 +86,8 @@ extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UIN ...@@ -86,8 +86,8 @@ extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UIN
WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg, WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg,
enum wm_char_mapping mapping ) DECLSPEC_HIDDEN; enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; extern INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; extern INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
extern void winproc_init(void) DECLSPEC_HIDDEN; extern void winproc_init(void) DECLSPEC_HIDDEN;
extern void dispatch_win_proc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; extern void dispatch_win_proc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN;
extern void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; extern void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN;
......
...@@ -1361,50 +1361,46 @@ LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg, WPARAM wParam ...@@ -1361,50 +1361,46 @@ LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg, WPARAM wParam
/********************************************************************** /**********************************************************************
* WINPROC_CallDlgProcA * WINPROC_CallDlgProcA
*/ */
INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{ {
WINDOWPROC *proc;
LRESULT result; LRESULT result;
INT_PTR ret; DLGPROC func;
if (!func) return 0; if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_ANSI ))) return 0;
if (!(proc = handle_to_proc( (WNDPROC)func ))) if (func == WINPROC_PROC16)
ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, func );
else if (proc == WINPROC_PROC16)
{ {
INT_PTR ret;
if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_WIN16 ))) return 0;
ret = wow_handlers.call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); ret = wow_handlers.call_dialog_proc( hwnd, msg, wParam, lParam, &result, func );
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result );
return ret;
} }
else
ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc->procW ? proc->procW : proc->procA );
return ret; return call_dialog_proc( hwnd, msg, wParam, lParam, &result, func );
} }
/********************************************************************** /**********************************************************************
* WINPROC_CallDlgProcW * WINPROC_CallDlgProcW
*/ */
INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{ {
WINDOWPROC *proc;
LRESULT result; LRESULT result;
INT_PTR ret; DLGPROC func;
if (!func) return 0; if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_UNICODE ))) return 0;
if (!(proc = handle_to_proc( (WNDPROC)func ))) if (func == WINPROC_PROC16)
ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, func );
else if (proc == WINPROC_PROC16)
{ {
INT_PTR ret;
if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_WIN16 ))) return 0;
ret = WINPROC_CallProcWtoA( wow_handlers.call_dialog_proc, hwnd, msg, wParam, lParam, &result, func ); ret = WINPROC_CallProcWtoA( wow_handlers.call_dialog_proc, hwnd, msg, wParam, lParam, &result, func );
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result );
return ret;
} }
else
ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc->procW ? proc->procW : proc->procA );
return ret; return call_dialog_proc( hwnd, msg, wParam, lParam, &result, func );
} }
......
...@@ -203,6 +203,31 @@ void get_winproc_params( struct win_proc_params *params ) ...@@ -203,6 +203,31 @@ void get_winproc_params( struct win_proc_params *params )
} }
} }
DLGPROC get_dialog_proc( HWND hwnd, enum dialog_proc_type type )
{
WINDOWPROC *proc;
DLGPROC ret;
WND *win;
if (!(win = get_win_ptr( hwnd ))) return NULL;
if (win == WND_OTHER_PROCESS || win == WND_DESKTOP)
{
ERR( "cannot get dlg proc %p from other process\n", hwnd );
return 0;
}
ret = *(DLGPROC *)((char *)win->wExtra + DWLP_DLGPROC);
release_win_ptr( win );
if (type == DLGPROC_WIN16 || !(proc = get_winproc_ptr( ret ))) return ret;
if (proc == WINPROC_PROC16) return WINPROC_PROC16;
if (type == DLGPROC_ANSI)
ret = proc->procA ? proc->procA : proc->procW;
else
ret = proc->procW ? proc->procW : proc->procA;
return ret;
}
/*********************************************************************** /***********************************************************************
* NtUserInitializeClientPfnArrays (win32u.@) * NtUserInitializeClientPfnArrays (win32u.@)
*/ */
......
...@@ -249,6 +249,7 @@ DWORD get_class_long( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; ...@@ -249,6 +249,7 @@ DWORD get_class_long( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN;
WNDPROC get_class_winproc( struct tagCLASS *class ) DECLSPEC_HIDDEN; WNDPROC get_class_winproc( struct tagCLASS *class ) DECLSPEC_HIDDEN;
ULONG_PTR get_class_long_ptr( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; ULONG_PTR get_class_long_ptr( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN;
WORD get_class_word( HWND hwnd, INT offset ) DECLSPEC_HIDDEN; WORD get_class_word( HWND hwnd, INT offset ) DECLSPEC_HIDDEN;
DLGPROC get_dialog_proc( HWND hwnd, enum dialog_proc_type type ) DECLSPEC_HIDDEN;
ATOM get_int_atom_value( UNICODE_STRING *name ) DECLSPEC_HIDDEN; ATOM get_int_atom_value( UNICODE_STRING *name ) DECLSPEC_HIDDEN;
WNDPROC get_winproc( WNDPROC proc, BOOL ansi ) DECLSPEC_HIDDEN; WNDPROC get_winproc( WNDPROC proc, BOOL ansi ) DECLSPEC_HIDDEN;
void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN;
......
...@@ -5484,6 +5484,9 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) ...@@ -5484,6 +5484,9 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code )
case NtUserCallHwndParam_GetClientRect: case NtUserCallHwndParam_GetClientRect:
return get_client_rect( hwnd, (RECT *)param ); return get_client_rect( hwnd, (RECT *)param );
case NtUserCallHwndParam_GetDialogProc:
return (ULONG_PTR)get_dialog_proc( hwnd, param );
case NtUserCallHwndParam_GetScrollInfo: case NtUserCallHwndParam_GetScrollInfo:
{ {
struct get_scroll_info_params *params = (void *)param; struct get_scroll_info_params *params = (void *)param;
......
...@@ -1206,6 +1206,7 @@ enum ...@@ -1206,6 +1206,7 @@ enum
NtUserCallHwndParam_GetClassLongPtrW, NtUserCallHwndParam_GetClassLongPtrW,
NtUserCallHwndParam_GetClassWord, NtUserCallHwndParam_GetClassWord,
NtUserCallHwndParam_GetClientRect, NtUserCallHwndParam_GetClientRect,
NtUserCallHwndParam_GetDialogProc,
NtUserCallHwndParam_GetScrollInfo, NtUserCallHwndParam_GetScrollInfo,
NtUserCallHwndParam_GetWindowInfo, NtUserCallHwndParam_GetWindowInfo,
NtUserCallHwndParam_GetWindowLongA, NtUserCallHwndParam_GetWindowLongA,
...@@ -1271,6 +1272,18 @@ static inline BOOL NtUserGetClientRect( HWND hwnd, RECT *rect ) ...@@ -1271,6 +1272,18 @@ static inline BOOL NtUserGetClientRect( HWND hwnd, RECT *rect )
return NtUserCallHwndParam( hwnd, (UINT_PTR)rect, NtUserCallHwndParam_GetClientRect ); return NtUserCallHwndParam( hwnd, (UINT_PTR)rect, NtUserCallHwndParam_GetClientRect );
} }
enum dialog_proc_type
{
DLGPROC_ANSI,
DLGPROC_UNICODE,
DLGPROC_WIN16,
};
static inline DLGPROC NtUserGetDialogProc( HWND hwnd, enum dialog_proc_type type )
{
return (DLGPROC)NtUserCallHwndParam( hwnd, type, NtUserCallHwndParam_GetDialogProc );
}
struct get_scroll_info_params struct get_scroll_info_params
{ {
int bar; int bar;
......
Supports Markdown
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