Replace 16-bit calls in DefWindowProc by 32-bit, preferring unicode

API calls.
This commit is contained in:
Dmitry Timoshkov 2001-01-26 00:19:33 +00:00 committed by Alexandre Julliard
parent 4d77fc44bc
commit 06e735d2ec
2 changed files with 62 additions and 40 deletions

View File

@ -178,7 +178,7 @@ extern void CARET_GetRect(LPRECT lprc); /* windows/caret.c */
extern BOOL16 DRAG_QueryUpdate( HWND, SEGPTR, BOOL ); extern BOOL16 DRAG_QueryUpdate( HWND, SEGPTR, BOOL );
extern void DEFWND_SetTextA( WND *wndPtr, LPCSTR text ); extern void DEFWND_SetTextA( WND *wndPtr, LPCSTR text );
extern void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text ); extern void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text );
extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT16 ctlType ); /* windows/defwnd.c */ extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ); /* windows/defwnd.c */
extern void PROPERTY_RemoveWindowProps( WND *pWnd ); /* windows/property.c */ extern void PROPERTY_RemoveWindowProps( WND *pWnd ); /* windows/property.c */

View File

@ -38,17 +38,17 @@ static short iMenuSysKey = 0;
*/ */
static void DEFWND_HandleWindowPosChanged( WND *wndPtr, UINT flags ) static void DEFWND_HandleWindowPosChanged( WND *wndPtr, UINT flags )
{ {
WPARAM16 wp = SIZE_RESTORED; WPARAM wp = SIZE_RESTORED;
if (!(flags & SWP_NOCLIENTMOVE)) if (!(flags & SWP_NOCLIENTMOVE))
SendMessage16( wndPtr->hwndSelf, WM_MOVE, 0, SendMessageW( wndPtr->hwndSelf, WM_MOVE, 0,
MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top)); MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top));
if (!(flags & SWP_NOCLIENTSIZE)) if (!(flags & SWP_NOCLIENTSIZE))
{ {
if (wndPtr->dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED; if (wndPtr->dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
else if (wndPtr->dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED; else if (wndPtr->dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
SendMessage16( wndPtr->hwndSelf, WM_SIZE, wp, SendMessageW( wndPtr->hwndSelf, WM_SIZE, wp,
MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left, MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
wndPtr->rectClient.bottom-wndPtr->rectClient.top)); wndPtr->rectClient.bottom-wndPtr->rectClient.top));
} }
@ -103,7 +103,7 @@ void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text )
* *
* Default colors for control painting. * Default colors for control painting.
*/ */
HBRUSH DEFWND_ControlColor( HDC hDC, UINT16 ctlType ) HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType )
{ {
if( ctlType == CTLCOLOR_SCROLLBAR) if( ctlType == CTLCOLOR_SCROLLBAR)
{ {
@ -203,13 +203,13 @@ static void DEFWND_Print(
* Background * Background
*/ */
if ( uFlags & PRF_ERASEBKGND) if ( uFlags & PRF_ERASEBKGND)
SendMessageA(wndPtr->hwndSelf, WM_ERASEBKGND, (WPARAM)hdc, 0); SendMessageW(wndPtr->hwndSelf, WM_ERASEBKGND, (WPARAM)hdc, 0);
/* /*
* Client area * Client area
*/ */
if ( uFlags & PRF_CLIENT) if ( uFlags & PRF_CLIENT)
SendMessageA(wndPtr->hwndSelf, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT); SendMessageW(wndPtr->hwndSelf, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
} }
@ -284,8 +284,14 @@ static BOOL DEFWND_ImmIsUIMessageW( HWND hwndIME, UINT msg, WPARAM wParam, LPARA
* Default window procedure for messages that are the same in Win16 and Win32. * Default window procedure for messages that are the same in Win16 and Win32.
*/ */
static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam, static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
LPARAM lParam ) LPARAM lParam, BOOL unicode )
{ {
LRESULT (WINAPI *pSendMessage)(HWND, UINT, WPARAM, LPARAM);
BOOL (WINAPI *pPostMessage)(HWND, UINT, WPARAM, LPARAM);
pSendMessage = unicode ? SendMessageW : SendMessageA;
pPostMessage = unicode ? PostMessageW : PostMessageA;
switch(msg) switch(msg)
{ {
case WM_NCPAINT: case WM_NCPAINT:
@ -322,9 +328,12 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
} }
if ((wndPtr->flags & WIN_ISWIN32) || (TWEAK_WineLook > WIN31_LOOK)) if ((wndPtr->flags & WIN_ISWIN32) || (TWEAK_WineLook > WIN31_LOOK))
{ {
ClientToScreen16(wndPtr->hwndSelf, (LPPOINT16)&lParam); POINT pt;
SendMessageA( wndPtr->hwndSelf, WM_CONTEXTMENU, pt.x = SLOWORD(lParam);
wndPtr->hwndSelf, lParam); pt.y = SHIWORD(lParam);
ClientToScreen(wndPtr->hwndSelf, &pt);
lParam = MAKELPARAM(pt.x, pt.y);
pSendMessage( wndPtr->hwndSelf, WM_CONTEXTMENU, wndPtr->hwndSelf, lParam );
} }
break; break;
@ -339,7 +348,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_CONTEXTMENU: case WM_CONTEXTMENU:
if( wndPtr->dwStyle & WS_CHILD ) if( wndPtr->dwStyle & WS_CHILD )
SendMessageA( wndPtr->parent->hwndSelf, msg, wParam, lParam ); pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam );
else if (wndPtr->hSysMenu) else if (wndPtr->hSysMenu)
{ {
LONG hitcode; LONG hitcode;
@ -384,12 +393,12 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_PAINTICON: case WM_PAINTICON:
case WM_PAINT: case WM_PAINT:
{ {
PAINTSTRUCT16 ps; PAINTSTRUCT ps;
HDC16 hdc = BeginPaint16( wndPtr->hwndSelf, &ps ); HDC hdc = BeginPaint( wndPtr->hwndSelf, &ps );
if( hdc ) if( hdc )
{ {
HICON hIcon; HICON hIcon;
if( (wndPtr->dwStyle & WS_MINIMIZE) && ((hIcon = GetClassLongA( wndPtr->hwndSelf, GCL_HICON))) ) if( (wndPtr->dwStyle & WS_MINIMIZE) && ((hIcon = GetClassLongW( wndPtr->hwndSelf, GCL_HICON))) )
{ {
int x = (wndPtr->rectWindow.right - wndPtr->rectWindow.left - int x = (wndPtr->rectWindow.right - wndPtr->rectWindow.left -
GetSystemMetrics(SM_CXICON))/2; GetSystemMetrics(SM_CXICON))/2;
@ -399,7 +408,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ); ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom );
DrawIcon( hdc, x, y, hIcon ); DrawIcon( hdc, x, y, hIcon );
} }
EndPaint16( wndPtr->hwndSelf, &ps ); EndPaint( wndPtr->hwndSelf, &ps );
} }
return 0; return 0;
} }
@ -423,7 +432,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_MOUSEACTIVATE: case WM_MOUSEACTIVATE:
if (wndPtr->dwStyle & WS_CHILD) if (wndPtr->dwStyle & WS_CHILD)
{ {
LONG ret = SendMessage16( wndPtr->parent->hwndSelf, LONG ret = pSendMessage( wndPtr->parent->hwndSelf,
WM_MOUSEACTIVATE, wParam, lParam ); WM_MOUSEACTIVATE, wParam, lParam );
if (ret) return ret; if (ret) return ret;
} }
@ -443,7 +452,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
if (wndPtr->dwStyle & WS_CHILD) if (wndPtr->dwStyle & WS_CHILD)
{ {
return SendMessageA( wndPtr->parent->hwndSelf, return pSendMessage( wndPtr->parent->hwndSelf,
WM_MOUSEWHEEL, wParam, lParam ); WM_MOUSEWHEEL, wParam, lParam );
} }
break; break;
@ -452,7 +461,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_ICONERASEBKGND: case WM_ICONERASEBKGND:
{ {
RECT rect; RECT rect;
HBRUSH hbr = GetClassLongA( wndPtr->hwndSelf, GCL_HBRBACKGROUND ); HBRUSH hbr = GetClassLongW( wndPtr->hwndSelf, GCL_HBRBACKGROUND );
if (!hbr) return 0; if (!hbr) return 0;
/* Since WM_ERASEBKGND may receive either a window dc or a */ /* Since WM_ERASEBKGND may receive either a window dc or a */
@ -490,7 +499,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_SETCURSOR: case WM_SETCURSOR:
if (wndPtr->dwStyle & WS_CHILD) if (wndPtr->dwStyle & WS_CHILD)
if (SendMessage16(wndPtr->parent->hwndSelf, WM_SETCURSOR, if (pSendMessage(wndPtr->parent->hwndSelf, WM_SETCURSOR,
wParam, lParam)) wParam, lParam))
return TRUE; return TRUE;
return NC_HandleSetCursor( wndPtr->hwndSelf, wParam, lParam ); return NC_HandleSetCursor( wndPtr->hwndSelf, wParam, lParam );
@ -523,7 +532,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
HWND hWnd = WIN_GetTopParent( wndPtr->hwndSelf ); HWND hWnd = WIN_GetTopParent( wndPtr->hwndSelf );
wndPtr = WIN_FindWndPtr( hWnd ); wndPtr = WIN_FindWndPtr( hWnd );
if( wndPtr && !(wndPtr->clsStyle & CS_NOCLOSE) ) if( wndPtr && !(wndPtr->clsStyle & CS_NOCLOSE) )
PostMessage16( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 ); pPostMessage( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
WIN_ReleaseWndPtr(wndPtr); WIN_ReleaseWndPtr(wndPtr);
} }
} }
@ -531,8 +540,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
iF10Key = 1; iF10Key = 1;
else else
if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000)) if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
SendMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND, pSendMessage( wndPtr->hwndSelf, WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE );
(WPARAM16)SC_KEYMENU, (LPARAM)VK_SPACE);
break; break;
case WM_KEYUP: case WM_KEYUP:
@ -540,7 +548,7 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
/* Press and release F10 or ALT */ /* Press and release F10 or ALT */
if (((wParam == VK_MENU) && iMenuSysKey) || if (((wParam == VK_MENU) && iMenuSysKey) ||
((wParam == VK_F10) && iF10Key)) ((wParam == VK_F10) && iF10Key))
SendMessage16( WIN_GetTopParent(wndPtr->hwndSelf), pSendMessage( WIN_GetTopParent(wndPtr->hwndSelf),
WM_SYSCOMMAND, SC_KEYMENU, 0L ); WM_SYSCOMMAND, SC_KEYMENU, 0L );
iMenuSysKey = iF10Key = 0; iMenuSysKey = iF10Key = 0;
break; break;
@ -549,18 +557,16 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
iMenuSysKey = 0; iMenuSysKey = 0;
if (wParam == VK_RETURN && (wndPtr->dwStyle & WS_MINIMIZE)) if (wParam == VK_RETURN && (wndPtr->dwStyle & WS_MINIMIZE))
{ {
PostMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND, pPostMessage( wndPtr->hwndSelf, WM_SYSCOMMAND, SC_RESTORE, 0L );
(WPARAM16)SC_RESTORE, 0L );
break; break;
} }
if ((HIWORD(lParam) & KEYDATA_ALT) && wParam) if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
{ {
if (wParam == VK_TAB || wParam == VK_ESCAPE) break; if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
if (wParam == VK_SPACE && (wndPtr->dwStyle & WS_CHILD)) if (wParam == VK_SPACE && (wndPtr->dwStyle & WS_CHILD))
SendMessage16( wndPtr->parent->hwndSelf, msg, wParam, lParam ); pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam );
else else
SendMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND, pSendMessage( wndPtr->hwndSelf, WM_SYSCOMMAND, SC_KEYMENU, wParam );
(WPARAM16)SC_KEYMENU, (LPARAM)(DWORD)wParam );
} }
else /* check for Ctrl-Esc */ else /* check for Ctrl-Esc */
if (wParam != VK_ESCAPE) MessageBeep(0); if (wParam != VK_ESCAPE) MessageBeep(0);
@ -593,14 +599,14 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_QUERYDRAGICON: case WM_QUERYDRAGICON:
{ {
UINT16 len; UINT len;
HICON hIcon = GetClassLongA( wndPtr->hwndSelf, GCL_HICON ); HICON hIcon = GetClassLongW( wndPtr->hwndSelf, GCL_HICON );
if (hIcon) return hIcon; if (hIcon) return hIcon;
for(len=1; len<64; len++) for(len=1; len<64; len++)
if((hIcon=LoadIconA(wndPtr->hInstance,MAKEINTRESOURCEA(len)))) if((hIcon = LoadIconW(wndPtr->hInstance, MAKEINTRESOURCEW(len))))
return (LRESULT)hIcon; return (LRESULT)hIcon;
return (LRESULT)LoadIconA(0,IDI_APPLICATIONA); return (LRESULT)LoadIconW(0, IDI_APPLICATIONW);
} }
break; break;
@ -618,8 +624,8 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_SETICON: case WM_SETICON:
{ {
int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM; int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
HICON16 hOldIcon = GetClassLongA(wndPtr->hwndSelf, index); HICON hOldIcon = GetClassLongW(wndPtr->hwndSelf, index);
SetClassLongA(wndPtr->hwndSelf, index, lParam); SetClassLongW(wndPtr->hwndSelf, index, lParam);
SetWindowPos(wndPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED SetWindowPos(wndPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
| SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE
@ -634,11 +640,11 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
case WM_GETICON: case WM_GETICON:
{ {
int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM; int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
return GetClassLongA(wndPtr->hwndSelf, index); return GetClassLongW(wndPtr->hwndSelf, index);
} }
case WM_HELP: case WM_HELP:
SendMessageA( wndPtr->parent->hwndSelf, msg, wParam, lParam ); pSendMessage( wndPtr->parent->hwndSelf, msg, wParam, lParam );
break; break;
} }
@ -710,7 +716,7 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
break; break;
default: default:
result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam ); result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, FALSE );
break; break;
} }
@ -820,7 +826,7 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
break; break;
default: default:
result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam ); result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, FALSE );
break; break;
} }
@ -864,6 +870,22 @@ LRESULT WINAPI DefWindowProcW(
} }
break; break;
case WM_NCCALCSIZE:
result = NC_HandleNCCalcSize( wndPtr, (RECT *)lParam );
break;
case WM_WINDOWPOSCHANGING:
result = WINPOS_HandleWindowPosChanging( wndPtr,
(WINDOWPOS *)lParam );
break;
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS * winPos = (WINDOWPOS *)lParam;
DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags );
}
break;
case WM_GETTEXT: case WM_GETTEXT:
if (wParam && wndPtr->text) if (wParam && wndPtr->text)
{ {
@ -894,7 +916,7 @@ LRESULT WINAPI DefWindowProcW(
break; break;
default: default:
result = DefWindowProcA( hwnd, msg, wParam, lParam ); result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam, TRUE );
break; break;
} }
WIN_ReleaseWndPtr(wndPtr); WIN_ReleaseWndPtr(wndPtr);