user: Separate the 16 and 32-bit versions of WINPROC_GetProc.

This commit is contained in:
Alexandre Julliard 2006-05-09 18:40:46 +02:00
parent 5326e304d0
commit 4c40190620
5 changed files with 58 additions and 48 deletions

View File

@ -149,7 +149,20 @@ static BOOL set_server_info( HWND hwnd, INT offset, LONG newval )
* *
* Get the class winproc for a given proc type * Get the class winproc for a given proc type
*/ */
static WNDPROC16 CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type ) static WNDPROC16 CLASS_GetProc16( CLASS *classPtr )
{
WNDPROC proc = classPtr->winprocA;
if (!proc) proc = classPtr->winprocW;
return WINPROC_GetProc16( proc );
}
/***********************************************************************
* CLASS_GetProc
*
* Get the class winproc for a given proc type
*/
static WNDPROC CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type )
{ {
WNDPROC proc = classPtr->winprocA; WNDPROC proc = classPtr->winprocA;
@ -170,10 +183,9 @@ static WNDPROC16 CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type )
* Set the class winproc for a given proc type. * Set the class winproc for a given proc type.
* Returns the previous window proc. * Returns the previous window proc.
*/ */
static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type ) static void CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type )
{ {
WNDPROC *proc = &classPtr->winprocA; WNDPROC *proc = &classPtr->winprocA;
WNDPROC16 ret;
if (classPtr->winprocW) if (classPtr->winprocW)
{ {
@ -182,7 +194,6 @@ static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE
*/ */
if (!*proc || type == WIN_PROC_32W) proc = &classPtr->winprocW; if (!*proc || type == WIN_PROC_32W) proc = &classPtr->winprocW;
} }
ret = WINPROC_GetProc( *proc, type );
*proc = WINPROC_AllocProc( newproc, type ); *proc = WINPROC_AllocProc( newproc, type );
/* now clear the one that we didn't set */ /* now clear the one that we didn't set */
if (classPtr->winprocA && classPtr->winprocW) if (classPtr->winprocA && classPtr->winprocW)
@ -192,7 +203,6 @@ static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE
else else
classPtr->winprocA = 0; classPtr->winprocA = 0;
} }
return ret;
} }
@ -730,7 +740,7 @@ LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
case GCLP_WNDPROC: case GCLP_WNDPROC:
if (!(class = get_class_ptr( hwnd, FALSE ))) return 0; if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
if (class == CLASS_OTHER_PROCESS) break; if (class == CLASS_OTHER_PROCESS) break;
ret = (LONG)CLASS_GetProc( class, WIN_PROC_16 ); ret = (LONG)CLASS_GetProc16( class );
release_class_ptr( class ); release_class_ptr( class );
return ret; return ret;
case GCLP_MENUNAME: case GCLP_MENUNAME:
@ -942,7 +952,8 @@ LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
{ {
case GCLP_WNDPROC: case GCLP_WNDPROC:
if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_16 ); retval = (LONG)CLASS_GetProc16( class );
CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_16 );
release_class_ptr( class ); release_class_ptr( class );
return retval; return retval;
case GCLP_MENUNAME: case GCLP_MENUNAME:
@ -982,7 +993,8 @@ DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
retval = 0; /* Old value is now meaningless anyway */ retval = 0; /* Old value is now meaningless anyway */
break; break;
case GCLP_WNDPROC: case GCLP_WNDPROC:
retval = (DWORD)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W ); retval = (DWORD)CLASS_GetProc( class, WIN_PROC_32W );
CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W );
break; break;
case GCLP_HBRBACKGROUND: case GCLP_HBRBACKGROUND:
retval = (DWORD)class->hbrBackground; retval = (DWORD)class->hbrBackground;
@ -1048,7 +1060,10 @@ DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
if (!(class = get_class_ptr( hwnd, TRUE ))) return 0; if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
if (offset == GCLP_WNDPROC) if (offset == GCLP_WNDPROC)
retval = (DWORD)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A ); {
retval = (DWORD)CLASS_GetProc( class, WIN_PROC_32A );
CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A );
}
else /* GCL_MENUNAME */ else /* GCL_MENUNAME */
{ {
CLASS_SetMenuNameA( class, (LPCSTR)newval ); CLASS_SetMenuNameA( class, (LPCSTR)newval );

View File

@ -2165,7 +2165,7 @@ LONG WINAPI GetWindowLong16( HWND16 hwnd, INT16 offset )
} }
} }
retvalue = GetWindowLongA( WIN_Handle32(hwnd), offset ); retvalue = GetWindowLongA( WIN_Handle32(hwnd), offset );
if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc( (WNDPROC)retvalue, WIN_PROC_16 ); if (is_winproc) retvalue = (LONG_PTR)WINPROC_GetProc16( (WNDPROC)retvalue );
return retvalue; return retvalue;
} }
@ -2215,7 +2215,7 @@ LONG WINAPI SetWindowLong16( HWND16 hwnd, INT16 offset, LONG newval )
{ {
WNDPROC new_proc = WINPROC_AllocProc( (WNDPROC)newval, WIN_PROC_16 ); WNDPROC new_proc = WINPROC_AllocProc( (WNDPROC)newval, WIN_PROC_16 );
WNDPROC old_proc = (WNDPROC)SetWindowLongA( WIN_Handle32(hwnd), offset, (LONG_PTR)new_proc ); WNDPROC old_proc = (WNDPROC)SetWindowLongA( WIN_Handle32(hwnd), offset, (LONG_PTR)new_proc );
return (LONG)WINPROC_GetProc( (WNDPROC)old_proc, WIN_PROC_16 ); return (LONG)WINPROC_GetProc16( (WNDPROC)old_proc );
} }
else return SetWindowLongA( WIN_Handle32(hwnd), offset, newval ); else return SetWindowLongA( WIN_Handle32(hwnd), offset, newval );
} }

View File

@ -528,35 +528,44 @@ static WINDOWPROC *WINPROC_GetPtr( WNDPROC handle )
} }
/**********************************************************************
* WINPROC_GetProc16
*
* Get a window procedure pointer that can be passed to the Windows program.
*/
WNDPROC16 WINPROC_GetProc16( WNDPROC proc )
{
WINDOWPROC *ptr = (WINDOWPROC *)proc;
if (!proc) return 0;
if (ptr->type == WIN_PROC_16)
return ptr->thunk.t_from32.proc;
else
return (WNDPROC16)MAKESEGPTR( get_winproc_selector(),
(char *)&ptr->thunk - (char *)winproc_array );
}
/********************************************************************** /**********************************************************************
* WINPROC_GetProc * WINPROC_GetProc
* *
* Get a window procedure pointer that can be passed to the Windows program. * Get a window procedure pointer that can be passed to the Windows program.
*/ */
WNDPROC16 WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type ) WNDPROC WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type )
{ {
WINDOWPROC *ptr = (WINDOWPROC *)proc; WINDOWPROC *ptr = (WINDOWPROC *)proc;
if (!proc) return NULL; if (!proc) return NULL;
if (type == WIN_PROC_16) /* We want a 16:16 address */
{ if (ptr->type == WIN_PROC_16)
if (ptr->type == WIN_PROC_16) return (WNDPROC)&ptr->thunk;
return ptr->thunk.t_from32.proc; else if (type != ptr->type)
else /* Have to return the jmp address if types don't match */
return (WNDPROC16)MAKESEGPTR( get_winproc_selector(), return (WNDPROC)&ptr->jmp;
(char *)&ptr->thunk - (char *)winproc_array ); else
} /* Some Win16 programs want to get back the proc they set */
else /* We want a 32-bit address */ return (WNDPROC)ptr->thunk.t_from16.proc;
{
if (ptr->type == WIN_PROC_16)
return (WNDPROC16)&ptr->thunk;
else if (type != ptr->type)
/* Have to return the jmp address if types don't match */
return (WNDPROC16)&ptr->jmp;
else
/* Some Win16 programs want to get back the proc they set */
return (WNDPROC16)ptr->thunk.t_from16.proc;
}
} }
@ -3205,11 +3214,6 @@ LRESULT WINAPI CallWindowProc16( WNDPROC16 func, HWND16 hwnd, UINT16 msg,
if (!(proc = WINPROC_GetPtr( (WNDPROC)func ))) if (!(proc = WINPROC_GetPtr( (WNDPROC)func )))
return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam ); return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam );
#if testing
func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_16 );
return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam );
#endif
switch(proc->type) switch(proc->type)
{ {
case WIN_PROC_16: case WIN_PROC_16:
@ -3267,11 +3271,6 @@ LRESULT WINAPI CallWindowProcA(
if (!(proc = WINPROC_GetPtr( func ))) if (!(proc = WINPROC_GetPtr( func )))
return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
#if testing
func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_32A );
return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
#endif
switch(proc->type) switch(proc->type)
{ {
case WIN_PROC_16: case WIN_PROC_16:
@ -3308,11 +3307,6 @@ LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg,
if (!(proc = WINPROC_GetPtr( (WNDPROC)func ))) if (!(proc = WINPROC_GetPtr( (WNDPROC)func )))
return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
#if testing
func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_32W );
return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
#endif
switch(proc->type) switch(proc->type)
{ {
case WIN_PROC_16: case WIN_PROC_16:

View File

@ -52,7 +52,8 @@ typedef struct
struct tagWINDOWPROC; struct tagWINDOWPROC;
extern WNDPROC16 WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type ); extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc );
extern WNDPROC WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type );
extern WNDPROC WINPROC_AllocProc( WNDPROC func, WINDOWPROCTYPE type ); extern WNDPROC WINPROC_AllocProc( WNDPROC func, WINDOWPROCTYPE type );
extern WINDOWPROCTYPE WINPROC_GetProcType( WNDPROC proc ); extern WINDOWPROCTYPE WINPROC_GetProcType( WNDPROC proc );

View File

@ -1358,7 +1358,7 @@ BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *
if (ret) if (ret)
{ {
WNDPROC proc = WINPROC_AllocProc( wc32.lpfnWndProc, WIN_PROC_32A ); WNDPROC proc = WINPROC_AllocProc( wc32.lpfnWndProc, WIN_PROC_32A );
wc->lpfnWndProc = WINPROC_GetProc( proc, WIN_PROC_16 ); wc->lpfnWndProc = WINPROC_GetProc16( proc );
wc->style = wc32.style; wc->style = wc32.style;
wc->cbClsExtra = wc32.cbClsExtra; wc->cbClsExtra = wc32.cbClsExtra;
wc->cbWndExtra = wc32.cbWndExtra; wc->cbWndExtra = wc32.cbWndExtra;