2 * Default window procedure
4 * Copyright 1993, 1996 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "nonclient.h"
34 #include "wine/unicode.h"
35 #include "wine/winuser16.h"
36 #include "wine/server.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(win);
41 /* bits in the dwKeyData */
42 #define KEYDATA_ALT 0x2000
43 #define KEYDATA_PREVSTATE 0x4000
45 static short iF10Key = 0;
46 static short iMenuSysKey = 0;
48 /***********************************************************************
49 * DEFWND_HandleWindowPosChanged
51 * Handle the WM_WINDOWPOSCHANGED message.
53 static void DEFWND_HandleWindowPosChanged( HWND hwnd, UINT flags )
56 WND *wndPtr = WIN_GetPtr( hwnd );
58 rect = wndPtr->rectClient;
59 WIN_ReleasePtr( wndPtr );
61 if (!(flags & SWP_NOCLIENTMOVE))
62 SendMessageW( hwnd, WM_MOVE, 0, MAKELONG(rect.left, rect.top));
64 if (!(flags & SWP_NOCLIENTSIZE))
66 WPARAM wp = SIZE_RESTORED;
67 if (IsZoomed(hwnd)) wp = SIZE_MAXIMIZED;
68 else if (IsIconic(hwnd)) wp = SIZE_MINIMIZED;
70 SendMessageW( hwnd, WM_SIZE, wp, MAKELONG(rect.right-rect.left, rect.bottom-rect.top) );
75 /***********************************************************************
78 * Set the window text.
80 static void DEFWND_SetTextA( HWND hwnd, LPCSTR text )
87 count = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
89 if (!(wndPtr = WIN_GetPtr( hwnd ))) return;
90 if ((textW = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR))))
92 if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text);
94 MultiByteToWideChar( CP_ACP, 0, text, -1, textW, count );
95 SERVER_START_REQ( set_window_text )
98 wine_server_add_data( req, textW, (count-1) * sizeof(WCHAR) );
99 wine_server_call( req );
104 ERR("Not enough memory for window text\n");
105 WIN_ReleasePtr( wndPtr );
107 if (USER_Driver.pSetWindowText) USER_Driver.pSetWindowText( hwnd, textW );
110 /***********************************************************************
113 * Set the window text.
115 static void DEFWND_SetTextW( HWND hwnd, LPCWSTR text )
117 static const WCHAR empty_string[] = {0};
121 if (!text) text = empty_string;
122 count = strlenW(text) + 1;
124 if (!(wndPtr = WIN_GetPtr( hwnd ))) return;
125 if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text);
126 if ((wndPtr->text = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR))))
128 strcpyW( wndPtr->text, text );
129 SERVER_START_REQ( set_window_text )
132 wine_server_add_data( req, wndPtr->text, (count-1) * sizeof(WCHAR) );
133 wine_server_call( req );
138 ERR("Not enough memory for window text\n");
140 WIN_ReleasePtr( wndPtr );
142 if (USER_Driver.pSetWindowText) USER_Driver.pSetWindowText( hwnd, text );
145 /***********************************************************************
146 * DEFWND_ControlColor
148 * Default colors for control painting.
150 HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType )
152 if( ctlType == CTLCOLOR_SCROLLBAR)
154 HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
155 if (TWEAK_WineLook == WIN31_LOOK) {
156 SetTextColor( hDC, RGB(0, 0, 0) );
157 SetBkColor( hDC, RGB(255, 255, 255) );
159 COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
160 SetTextColor( hDC, GetSysColor(COLOR_3DFACE));
161 SetBkColor( hDC, bk);
163 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
164 * we better use 0x55aa bitmap brush to make scrollbar's background
165 * look different from the window background.
167 if (bk == GetSysColor(COLOR_WINDOW)) {
168 return CACHE_GetPattern55AABrush();
171 UnrealizeObject( hb );
175 SetTextColor( hDC, GetSysColor(COLOR_WINDOWTEXT));
177 if (TWEAK_WineLook > WIN31_LOOK) {
178 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
179 SetBkColor( hDC, GetSysColor(COLOR_WINDOW) );
181 SetBkColor( hDC, GetSysColor(COLOR_3DFACE) );
182 return GetSysColorBrush(COLOR_3DFACE);
186 SetBkColor( hDC, GetSysColor(COLOR_WINDOW) );
187 return GetSysColorBrush(COLOR_WINDOW);
191 /***********************************************************************
194 static void DEFWND_SetRedraw( HWND hwnd, WPARAM wParam )
196 WND *wndPtr = WIN_FindWndPtr( hwnd );
197 BOOL bVisible = wndPtr->dwStyle & WS_VISIBLE;
199 TRACE("%p %i\n", hwnd, (wParam!=0) );
205 WIN_SetStyle( hwnd, wndPtr->dwStyle | WS_VISIBLE );
206 DCE_InvalidateDCE( hwnd, &wndPtr->rectWindow );
211 if( wndPtr->dwStyle & WS_MINIMIZE ) wParam = RDW_VALIDATE;
212 else wParam = RDW_ALLCHILDREN | RDW_VALIDATE;
214 RedrawWindow( hwnd, NULL, 0, wParam );
215 DCE_InvalidateDCE( hwnd, &wndPtr->rectWindow );
216 WIN_SetStyle( hwnd, wndPtr->dwStyle & ~WS_VISIBLE );
218 WIN_ReleaseWndPtr( wndPtr );
221 /***********************************************************************
224 * This method handles the default behavior for the WM_PRINT message.
226 static void DEFWND_Print( HWND hwnd, HDC hdc, ULONG uFlags)
231 if ( (uFlags & PRF_CHECKVISIBLE) &&
232 !IsWindowVisible(hwnd) )
236 * Unimplemented flags.
238 if ( (uFlags & PRF_CHILDREN) ||
239 (uFlags & PRF_OWNED) ||
240 (uFlags & PRF_NONCLIENT) )
242 WARN("WM_PRINT message with unsupported flags\n");
248 if ( uFlags & PRF_ERASEBKGND)
249 SendMessageW(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
254 if ( uFlags & PRF_CLIENT)
255 SendMessageW(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
260 * helpers for calling IMM32
262 * WM_IME_* messages are generated only by IMM32,
263 * so I assume imm32 is already LoadLibrary-ed.
265 static HWND DEFWND_ImmGetDefaultIMEWnd( HWND hwnd )
267 HINSTANCE hInstIMM = GetModuleHandleA( "imm32" );
268 HWND (WINAPI *pFunc)(HWND);
273 ERR( "cannot get IMM32 handle\n" );
277 pFunc = (void*)GetProcAddress(hInstIMM,"ImmGetDefaultIMEWnd");
279 hwndRet = (*pFunc)( hwnd );
284 static BOOL DEFWND_ImmIsUIMessageA( HWND hwndIME, UINT msg, WPARAM wParam, LPARAM lParam )
286 HINSTANCE hInstIMM = GetModuleHandleA( "imm32" );
287 BOOL (WINAPI *pFunc)(HWND,UINT,WPARAM,LPARAM);
292 ERR( "cannot get IMM32 handle\n" );
296 pFunc = (void*)GetProcAddress(hInstIMM,"ImmIsUIMessageA");
298 fRet = (*pFunc)( hwndIME, msg, wParam, lParam );
303 static BOOL DEFWND_ImmIsUIMessageW( HWND hwndIME, UINT msg, WPARAM wParam, LPARAM lParam )
305 HINSTANCE hInstIMM = GetModuleHandleA( "imm32" );
306 BOOL (WINAPI *pFunc)(HWND,UINT,WPARAM,LPARAM);
311 ERR( "cannot get IMM32 handle\n" );
315 pFunc = (void*)GetProcAddress(hInstIMM,"ImmIsUIMessageW");
317 fRet = (*pFunc)( hwndIME, msg, wParam, lParam );
324 /***********************************************************************
327 * Default window procedure for messages that are the same in Win16 and Win32.
329 static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
334 return NC_HandleNCPaint( hwnd, (HRGN)wParam );
339 pt.x = SLOWORD(lParam);
340 pt.y = SHIWORD(lParam);
341 return NC_HandleNCHitTest( hwnd, pt );
344 case WM_NCLBUTTONDOWN:
345 return NC_HandleNCLButtonDown( hwnd, wParam, lParam );
347 case WM_LBUTTONDBLCLK:
348 case WM_NCLBUTTONDBLCLK:
349 return NC_HandleNCLButtonDblClk( hwnd, wParam, lParam );
351 case WM_NCRBUTTONDOWN:
352 /* in Windows, capture is taken when right-clicking on the caption bar */
353 if (wParam==HTCAPTION)
363 if (hwnd == GetCapture())
364 /* release capture if we took it on WM_NCRBUTTONDOWN */
367 pt.x = SLOWORD(lParam);
368 pt.y = SHIWORD(lParam);
369 ClientToScreen(hwnd, &pt);
370 SendMessageW( hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, MAKELPARAM(pt.x, pt.y) );
376 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
377 * in Windows), but what _should_ we do? According to MSDN :
378 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
379 * message to the window". When is it appropriate?
384 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
385 SendMessageW( GetParent(hwnd), msg, wParam, lParam );
390 WND *wndPtr = WIN_GetPtr( hwnd );
391 HMENU hMenu = wndPtr->hSysMenu;
392 WIN_ReleasePtr( wndPtr );
393 if (!hMenu) return 0;
394 pt.x = SLOWORD(lParam);
395 pt.y = SHIWORD(lParam);
396 hitcode = NC_HandleNCHitTest(hwnd, pt);
398 /* Track system popup if click was in the caption area. */
399 if (hitcode==HTCAPTION || hitcode==HTSYSMENU)
400 TrackPopupMenu(GetSystemMenu(hwnd, FALSE),
401 TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
402 pt.x, pt.y, 0, hwnd, NULL);
407 return NC_HandleNCActivate( hwnd, wParam );
411 WND *wndPtr = WIN_GetPtr( hwnd );
412 if (!wndPtr) return 0;
413 if (wndPtr->text) HeapFree( GetProcessHeap(), 0, wndPtr->text );
415 if (wndPtr->pVScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pVScroll );
416 if (wndPtr->pHScroll) HeapFree( GetProcessHeap(), 0, wndPtr->pHScroll );
417 wndPtr->pVScroll = wndPtr->pHScroll = NULL;
418 WIN_ReleasePtr( wndPtr );
423 DEFWND_Print(hwnd, (HDC)wParam, lParam);
430 HDC hdc = BeginPaint( hwnd, &ps );
434 if (IsIconic(hwnd) && ((hIcon = (HICON)GetClassLongW( hwnd, GCL_HICON))) )
439 GetClientRect( hwnd, &rc );
440 x = (rc.right - rc.left - GetSystemMetrics(SM_CXICON))/2;
441 y = (rc.bottom - rc.top - GetSystemMetrics(SM_CYICON))/2;
442 TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
443 ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom );
444 DrawIcon( hdc, x, y, hIcon );
446 EndPaint( hwnd, &ps );
452 RedrawWindow ( hwnd, NULL, 0, RDW_ERASENOW | RDW_ERASE | RDW_ALLCHILDREN );
456 DEFWND_SetRedraw( hwnd, wParam );
460 DestroyWindow( hwnd );
463 case WM_MOUSEACTIVATE:
464 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
466 LONG ret = SendMessageW( GetParent(hwnd), WM_MOUSEACTIVATE, wParam, lParam );
470 /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
471 return (LOWORD(lParam) >= HTCLIENT) ? MA_ACTIVATE : MA_NOACTIVATE;
474 /* The default action in Windows is to set the keyboard focus to
475 * the window, if it's being activated and not minimized */
476 if (LOWORD(wParam) != WA_INACTIVE) {
477 if (!IsIconic(hwnd)) SetFocus(hwnd);
482 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
483 return SendMessageW( GetParent(hwnd), WM_MOUSEWHEEL, wParam, lParam );
487 case WM_ICONERASEBKGND:
490 HDC hdc = (HDC)wParam;
491 HBRUSH hbr = (HBRUSH)GetClassLongW( hwnd, GCL_HBRBACKGROUND );
494 if (GetClassLongW( hwnd, GCL_STYLE ) & CS_PARENTDC)
496 /* can't use GetClipBox with a parent DC or we fill the whole parent */
497 GetClientRect( hwnd, &rect );
498 DPtoLP( hdc, (LPPOINT)&rect, 2 );
500 else GetClipBox( hdc, &rect );
501 FillRect( hdc, &rect, hbr );
508 case WM_CTLCOLORMSGBOX:
509 case WM_CTLCOLOREDIT:
510 case WM_CTLCOLORLISTBOX:
513 case WM_CTLCOLORSTATIC:
514 case WM_CTLCOLORSCROLLBAR:
515 return (LRESULT)DEFWND_ControlColor( (HDC)wParam, msg - WM_CTLCOLORMSGBOX );
518 return (LRESULT)DEFWND_ControlColor( (HDC)wParam, HIWORD(lParam) );
521 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
523 /* with the exception of the border around a resizable wnd,
524 * give the parent first chance to set the cursor */
525 if ((LOWORD(lParam) < HTSIZEFIRST) || (LOWORD(lParam) > HTSIZELAST))
527 if (SendMessageW(GetParent(hwnd), WM_SETCURSOR, wParam, lParam)) return TRUE;
530 NC_HandleSetCursor( hwnd, wParam, lParam );
534 return NC_HandleSysCommand( hwnd, wParam, lParam );
537 if(wParam == VK_F10) iF10Key = VK_F10;
541 if( HIWORD(lParam) & KEYDATA_ALT )
543 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
544 if( wParam == VK_MENU && !iMenuSysKey )
551 if( wParam == VK_F4 ) /* try to close the window */
553 HWND top = GetAncestor( hwnd, GA_ROOT );
554 if (!(GetClassLongW( top, GCL_STYLE ) & CS_NOCLOSE))
555 PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
558 else if( wParam == VK_F10 )
561 if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
562 SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE );
567 /* Press and release F10 or ALT */
568 if (((wParam == VK_MENU) && iMenuSysKey) ||
569 ((wParam == VK_F10) && iF10Key))
570 SendMessageW( GetAncestor( hwnd, GA_ROOT ), WM_SYSCOMMAND, SC_KEYMENU, 0L );
571 iMenuSysKey = iF10Key = 0;
576 if (wParam == VK_RETURN && IsIconic(hwnd))
578 PostMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0L );
581 if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
583 if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
584 if (wParam == VK_SPACE && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD))
585 SendMessageW( GetParent(hwnd), msg, wParam, lParam );
587 SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, wParam );
589 else /* check for Ctrl-Esc */
590 if (wParam != VK_ESCAPE) MessageBeep(0);
595 LONG style = GetWindowLongW( hwnd, GWL_STYLE );
596 if (!lParam) return 0; /* sent from ShowWindow */
597 if (!(style & WS_POPUP)) return 0;
598 if ((style & WS_VISIBLE) && wParam) return 0;
599 if (!(style & WS_VISIBLE) && !wParam) return 0;
600 if (!GetWindow( hwnd, GW_OWNER )) return 0;
601 ShowWindow( hwnd, wParam ? SW_SHOWNOACTIVATE : SW_HIDE );
606 if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)) EndMenu();
607 if (GetCapture() == hwnd) ReleaseCapture();
617 case WM_QUERYDROPOBJECT:
618 return (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES) != 0;
620 case WM_QUERYDRAGICON:
624 HICON hIcon = (HICON)GetClassLongW( hwnd, GCL_HICON );
625 HINSTANCE instance = (HINSTANCE)GetWindowLongW( hwnd, GWL_HINSTANCE );
626 if (hIcon) return (LRESULT)hIcon;
627 for(len=1; len<64; len++)
628 if((hIcon = LoadIconW(instance, MAKEINTRESOURCEW(len))))
629 return (LRESULT)hIcon;
630 return (LRESULT)LoadIconW(0, IDI_APPLICATIONW);
634 case WM_ISACTIVEICON:
636 WND *wndPtr = WIN_GetPtr( hwnd );
637 BOOL ret = (wndPtr->flags & WIN_NCACTIVATED) != 0;
638 WIN_ReleasePtr( wndPtr );
642 case WM_NOTIFYFORMAT:
643 if (IsWindowUnicode(hwnd)) return NFR_UNICODE;
644 else return NFR_ANSI;
647 case WM_QUERYENDSESSION:
651 if (USER_Driver.pSetWindowIcon)
652 return (LRESULT)USER_Driver.pSetWindowIcon( hwnd, (HICON)lParam, (wParam != ICON_SMALL) );
655 HICON hOldIcon = (HICON)SetClassLongW( hwnd, (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM,
657 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE |
658 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
659 return (LRESULT)hOldIcon;
663 return GetClassLongW( hwnd, (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM );
666 SendMessageW( GetParent(hwnd), msg, wParam, lParam );
675 /***********************************************************************
676 * DefWindowProc (USER.107)
678 LRESULT WINAPI DefWindowProc16( HWND16 hwnd16, UINT16 msg, WPARAM16 wParam,
682 HWND hwnd = WIN_Handle32( hwnd16 );
684 if (!WIN_IsCurrentProcess( hwnd ))
686 if (!IsWindow( hwnd )) return 0;
687 ERR( "called for other process window %p\n", hwnd );
690 SPY_EnterMessage( SPY_DEFWNDPROC16, hwnd, msg, wParam, lParam );
696 CREATESTRUCT16 *cs = MapSL(lParam);
697 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
698 * may have child window IDs instead of window name */
699 if (HIWORD(cs->lpszName))
700 DEFWND_SetTextA( hwnd, MapSL(cs->lpszName) );
708 CONV_RECT16TO32( MapSL(lParam), &rect32 );
709 result = NC_HandleNCCalcSize( hwnd, &rect32 );
710 CONV_RECT32TO16( &rect32, MapSL(lParam) );
714 case WM_WINDOWPOSCHANGING:
715 result = WINPOS_HandleWindowPosChanging16( hwnd, MapSL(lParam) );
718 case WM_WINDOWPOSCHANGED:
720 WINDOWPOS16 * winPos = MapSL(lParam);
721 DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
727 result = DefWindowProcA( hwnd, msg, wParam, (LPARAM)MapSL(lParam) );
731 result = DefWindowProcA( hwnd, msg, wParam, lParam );
735 SPY_ExitMessage( SPY_RESULT_DEFWND16, hwnd, msg, result, wParam, lParam );
740 /***********************************************************************
741 * DefWindowProcA (USER32.@)
744 LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
749 if (!(full_handle = WIN_IsCurrentProcess( hwnd )))
751 if (!IsWindow( hwnd )) return 0;
752 ERR( "called for other process window %p\n", hwnd );
757 SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
763 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
764 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
765 * may have child window IDs instead of window name */
766 if (HIWORD(cs->lpszName))
767 DEFWND_SetTextA( hwnd, cs->lpszName );
773 result = NC_HandleNCCalcSize( hwnd, (RECT *)lParam );
776 case WM_WINDOWPOSCHANGING:
777 result = WINPOS_HandleWindowPosChanging( hwnd, (WINDOWPOS *)lParam );
780 case WM_WINDOWPOSCHANGED:
782 WINDOWPOS * winPos = (WINDOWPOS *)lParam;
783 DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
787 case WM_GETTEXTLENGTH:
789 WND *wndPtr = WIN_GetPtr( hwnd );
790 if (wndPtr && wndPtr->text)
791 result = WideCharToMultiByte( CP_ACP, 0, wndPtr->text, strlenW(wndPtr->text),
792 NULL, 0, NULL, NULL );
793 WIN_ReleasePtr( wndPtr );
800 LPSTR dest = (LPSTR)lParam;
801 WND *wndPtr = WIN_GetPtr( hwnd );
806 if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1,
807 dest, wParam, NULL, NULL )) dest[wParam-1] = 0;
808 result = strlen( dest );
811 WIN_ReleasePtr( wndPtr );
816 DEFWND_SetTextA( hwnd, (LPCSTR)lParam );
817 if( (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CAPTION) == WS_CAPTION )
818 NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
819 result = 1; /* success. FIXME: check text length */
822 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
825 CHAR chChar1 = (CHAR)( (wParam>>8) & 0xff );
826 CHAR chChar2 = (CHAR)( wParam & 0xff );
828 SendMessageA( hwnd, WM_CHAR, (WPARAM)chChar1, lParam );
829 if ( IsDBCSLeadByte( chChar1 ) )
830 SendMessageA( hwnd, WM_CHAR, (WPARAM)chChar2, lParam );
834 result = SendMessageA( hwnd, WM_KEYDOWN, wParam, lParam );
837 result = SendMessageA( hwnd, WM_KEYUP, wParam, lParam );
840 case WM_IME_STARTCOMPOSITION:
841 case WM_IME_COMPOSITION:
842 case WM_IME_ENDCOMPOSITION:
847 hwndIME = DEFWND_ImmGetDefaultIMEWnd( hwnd );
849 result = SendMessageA( hwndIME, msg, wParam, lParam );
852 case WM_IME_SETCONTEXT:
856 hwndIME = DEFWND_ImmGetDefaultIMEWnd( hwnd );
858 result = DEFWND_ImmIsUIMessageA( hwndIME, msg, wParam, lParam );
863 result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam );
867 SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam );
872 /***********************************************************************
873 * DefWindowProcW (USER32.@) Calls default window message handler
875 * Calls default window procedure for messages not processed
879 * Return value is dependent upon the message.
881 LRESULT WINAPI DefWindowProcW(
882 HWND hwnd, /* [in] window procedure receiving message */
883 UINT msg, /* [in] message identifier */
884 WPARAM wParam, /* [in] first message parameter */
885 LPARAM lParam ) /* [in] second message parameter */
890 if (!(full_handle = WIN_IsCurrentProcess( hwnd )))
892 if (!IsWindow( hwnd )) return 0;
893 ERR( "called for other process window %p\n", hwnd );
897 SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
903 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
904 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
905 * may have child window IDs instead of window name */
906 if (HIWORD(cs->lpszName))
907 DEFWND_SetTextW( hwnd, cs->lpszName );
913 result = NC_HandleNCCalcSize( hwnd, (RECT *)lParam );
916 case WM_WINDOWPOSCHANGING:
917 result = WINPOS_HandleWindowPosChanging( hwnd, (WINDOWPOS *)lParam );
920 case WM_WINDOWPOSCHANGED:
922 WINDOWPOS * winPos = (WINDOWPOS *)lParam;
923 DEFWND_HandleWindowPosChanged( hwnd, winPos->flags );
927 case WM_GETTEXTLENGTH:
929 WND *wndPtr = WIN_GetPtr( hwnd );
930 if (wndPtr && wndPtr->text) result = (LRESULT)strlenW(wndPtr->text);
931 WIN_ReleasePtr( wndPtr );
938 LPWSTR dest = (LPWSTR)lParam;
939 WND *wndPtr = WIN_GetPtr( hwnd );
944 lstrcpynW( dest, wndPtr->text, wParam );
945 result = strlenW( dest );
948 WIN_ReleasePtr( wndPtr );
953 DEFWND_SetTextW( hwnd, (LPCWSTR)lParam );
954 if( (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CAPTION) == WS_CAPTION )
955 NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
956 result = 1; /* success. FIXME: check text length */
959 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
961 SendMessageW( hwnd, WM_CHAR, wParam, lParam );
963 case WM_IME_SETCONTEXT:
967 hwndIME = DEFWND_ImmGetDefaultIMEWnd( hwnd );
969 result = DEFWND_ImmIsUIMessageW( hwndIME, msg, wParam, lParam );
974 result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam );
977 SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam );