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
23 #include "wine/port.h"
34 #include "user_private.h"
37 #include "wine/unicode.h"
38 #include "wine/winuser16.h"
39 #include "wine/server.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(win
);
44 /* bits in the dwKeyData */
45 #define KEYDATA_ALT 0x2000
46 #define KEYDATA_PREVSTATE 0x4000
48 static short iF10Key
= 0;
49 static short iMenuSysKey
= 0;
50 static const WCHAR imm32W
[] = { 'i','m','m','3','2','\0' };
52 /***********************************************************************
53 * DEFWND_HandleWindowPosChanged
55 * Handle the WM_WINDOWPOSCHANGED message.
57 static void DEFWND_HandleWindowPosChanged( HWND hwnd
, const WINDOWPOS
*winpos
)
60 WND
*wndPtr
= WIN_GetPtr( hwnd
);
62 rect
= wndPtr
->rectClient
;
63 WIN_ReleasePtr( wndPtr
);
65 if (!(winpos
->flags
& SWP_NOCLIENTMOVE
))
66 SendMessageW( hwnd
, WM_MOVE
, 0, MAKELONG(rect
.left
, rect
.top
));
68 if (!(winpos
->flags
& SWP_NOCLIENTSIZE
))
70 WPARAM wp
= SIZE_RESTORED
;
71 if (IsZoomed(hwnd
)) wp
= SIZE_MAXIMIZED
;
72 else if (IsIconic(hwnd
)) wp
= SIZE_MINIMIZED
;
74 SendMessageW( hwnd
, WM_SIZE
, wp
, MAKELONG(rect
.right
-rect
.left
, rect
.bottom
-rect
.top
) );
79 /***********************************************************************
82 * Set the window text.
84 static void DEFWND_SetTextA( HWND hwnd
, LPCSTR text
)
91 count
= MultiByteToWideChar( CP_ACP
, 0, text
, -1, NULL
, 0 );
93 if (!(wndPtr
= WIN_GetPtr( hwnd
))) return;
94 if ((textW
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(WCHAR
))))
96 HeapFree(GetProcessHeap(), 0, wndPtr
->text
);
98 MultiByteToWideChar( CP_ACP
, 0, text
, -1, textW
, count
);
99 SERVER_START_REQ( set_window_text
)
102 wine_server_add_data( req
, textW
, (count
-1) * sizeof(WCHAR
) );
103 wine_server_call( req
);
108 ERR("Not enough memory for window text\n");
109 WIN_ReleasePtr( wndPtr
);
111 if (USER_Driver
.pSetWindowText
) USER_Driver
.pSetWindowText( hwnd
, textW
);
114 /***********************************************************************
117 * Set the window text.
119 static void DEFWND_SetTextW( HWND hwnd
, LPCWSTR text
)
121 static const WCHAR empty_string
[] = {0};
125 if (!text
) text
= empty_string
;
126 count
= strlenW(text
) + 1;
128 if (!(wndPtr
= WIN_GetPtr( hwnd
))) return;
129 HeapFree(GetProcessHeap(), 0, wndPtr
->text
);
130 if ((wndPtr
->text
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(WCHAR
))))
132 strcpyW( wndPtr
->text
, text
);
133 SERVER_START_REQ( set_window_text
)
136 wine_server_add_data( req
, wndPtr
->text
, (count
-1) * sizeof(WCHAR
) );
137 wine_server_call( req
);
142 ERR("Not enough memory for window text\n");
144 WIN_ReleasePtr( wndPtr
);
146 if (USER_Driver
.pSetWindowText
) USER_Driver
.pSetWindowText( hwnd
, text
);
149 /***********************************************************************
150 * DEFWND_ControlColor
152 * Default colors for control painting.
154 HBRUSH
DEFWND_ControlColor( HDC hDC
, UINT ctlType
)
156 if( ctlType
== CTLCOLOR_SCROLLBAR
)
158 HBRUSH hb
= GetSysColorBrush(COLOR_SCROLLBAR
);
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 SYSCOLOR_55AABrush
;
170 UnrealizeObject( hb
);
174 SetTextColor( hDC
, GetSysColor(COLOR_WINDOWTEXT
));
176 if ((ctlType
== CTLCOLOR_EDIT
) || (ctlType
== CTLCOLOR_LISTBOX
))
177 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
179 SetBkColor( hDC
, GetSysColor(COLOR_3DFACE
) );
180 return GetSysColorBrush(COLOR_3DFACE
);
182 return GetSysColorBrush(COLOR_WINDOW
);
186 /***********************************************************************
189 * This method handles the default behavior for the WM_PRINT message.
191 static void DEFWND_Print( HWND hwnd
, HDC hdc
, ULONG uFlags
)
196 if ( (uFlags
& PRF_CHECKVISIBLE
) &&
197 !IsWindowVisible(hwnd
) )
201 * Unimplemented flags.
203 if ( (uFlags
& PRF_CHILDREN
) ||
204 (uFlags
& PRF_OWNED
) ||
205 (uFlags
& PRF_NONCLIENT
) )
207 WARN("WM_PRINT message with unsupported flags\n");
213 if ( uFlags
& PRF_ERASEBKGND
)
214 SendMessageW(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
219 if ( uFlags
& PRF_CLIENT
)
220 SendMessageW(hwnd
, WM_PRINTCLIENT
, (WPARAM
)hdc
, PRF_CLIENT
);
225 * helpers for calling IMM32
227 * WM_IME_* messages are generated only by IMM32,
228 * so I assume imm32 is already LoadLibrary-ed.
230 static HWND
DEFWND_ImmGetDefaultIMEWnd( HWND hwnd
)
232 HINSTANCE hInstIMM
= GetModuleHandleW( imm32W
);
233 HWND (WINAPI
*pFunc
)(HWND
);
238 ERR( "cannot get IMM32 handle\n" );
242 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmGetDefaultIMEWnd");
244 hwndRet
= (*pFunc
)( hwnd
);
249 static BOOL
DEFWND_ImmIsUIMessageA( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
251 HINSTANCE hInstIMM
= GetModuleHandleW( imm32W
);
252 BOOL (WINAPI
*pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
257 ERR( "cannot get IMM32 handle\n" );
261 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageA");
263 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
268 static BOOL
DEFWND_ImmIsUIMessageW( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
270 HINSTANCE hInstIMM
= GetModuleHandleW( imm32W
);
271 BOOL (WINAPI
*pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
276 ERR( "cannot get IMM32 handle\n" );
280 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageW");
282 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
289 /***********************************************************************
292 * Default window procedure for messages that are the same in Ansi and Unicode.
294 static LRESULT
DEFWND_DefWinProc( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
299 return NC_HandleNCPaint( hwnd
, (HRGN
)wParam
);
304 pt
.x
= (short)LOWORD(lParam
);
305 pt
.y
= (short)HIWORD(lParam
);
306 return NC_HandleNCHitTest( hwnd
, pt
);
310 return NC_HandleNCCalcSize( hwnd
, (RECT
*)lParam
);
312 case WM_WINDOWPOSCHANGING
:
313 return WINPOS_HandleWindowPosChanging( hwnd
, (WINDOWPOS
*)lParam
);
315 case WM_WINDOWPOSCHANGED
:
316 DEFWND_HandleWindowPosChanged( hwnd
, (const WINDOWPOS
*)lParam
);
322 iF10Key
= iMenuSysKey
= 0;
325 case WM_NCLBUTTONDOWN
:
326 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
328 case WM_LBUTTONDBLCLK
:
329 case WM_NCLBUTTONDBLCLK
:
330 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
332 case WM_NCRBUTTONDOWN
:
333 /* in Windows, capture is taken when right-clicking on the caption bar */
334 if (wParam
==HTCAPTION
)
344 if (hwnd
== GetCapture())
345 /* release capture if we took it on WM_NCRBUTTONDOWN */
348 pt
.x
= (short)LOWORD(lParam
);
349 pt
.y
= (short)HIWORD(lParam
);
350 ClientToScreen(hwnd
, &pt
);
351 SendMessageW( hwnd
, WM_CONTEXTMENU
, (WPARAM
)hwnd
, MAKELPARAM(pt
.x
, pt
.y
) );
357 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
358 * in Windows), but what _should_ we do? According to MSDN :
359 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
360 * message to the window". When is it appropriate?
365 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)
366 SendMessageW( GetParent(hwnd
), msg
, wParam
, lParam
);
371 WND
*wndPtr
= WIN_GetPtr( hwnd
);
372 HMENU hMenu
= wndPtr
->hSysMenu
;
373 WIN_ReleasePtr( wndPtr
);
374 if (!hMenu
) return 0;
375 pt
.x
= (short)LOWORD(lParam
);
376 pt
.y
= (short)HIWORD(lParam
);
377 hitcode
= NC_HandleNCHitTest(hwnd
, pt
);
379 /* Track system popup if click was in the caption area. */
380 if (hitcode
==HTCAPTION
|| hitcode
==HTSYSMENU
)
381 TrackPopupMenu(GetSystemMenu(hwnd
, FALSE
),
382 TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
,
383 pt
.x
, pt
.y
, 0, hwnd
, NULL
);
388 return NC_HandleNCActivate( hwnd
, wParam
);
392 WND
*wndPtr
= WIN_GetPtr( hwnd
);
393 if (!wndPtr
) return 0;
394 HeapFree( GetProcessHeap(), 0, wndPtr
->text
);
396 HeapFree( GetProcessHeap(), 0, wndPtr
->pVScroll
);
397 HeapFree( GetProcessHeap(), 0, wndPtr
->pHScroll
);
398 wndPtr
->pVScroll
= wndPtr
->pHScroll
= NULL
;
399 WIN_ReleasePtr( wndPtr
);
404 DEFWND_Print(hwnd
, (HDC
)wParam
, lParam
);
411 HDC hdc
= BeginPaint( hwnd
, &ps
);
415 if (IsIconic(hwnd
) && ((hIcon
= (HICON
)GetClassLongPtrW( hwnd
, GCLP_HICON
))) )
420 GetClientRect( hwnd
, &rc
);
421 x
= (rc
.right
- rc
.left
- GetSystemMetrics(SM_CXICON
))/2;
422 y
= (rc
.bottom
- rc
.top
- GetSystemMetrics(SM_CYICON
))/2;
423 TRACE("Painting class icon: vis rect=(%ld,%ld - %ld,%ld)\n",
424 ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
425 DrawIcon( hdc
, x
, y
, hIcon
);
427 EndPaint( hwnd
, &ps
);
433 RedrawWindow ( hwnd
, NULL
, 0, RDW_ERASENOW
| RDW_ERASE
| RDW_ALLCHILDREN
);
437 if (wParam
) WIN_SetStyle( hwnd
, WS_VISIBLE
, 0 );
440 RedrawWindow( hwnd
, NULL
, 0, RDW_ALLCHILDREN
| RDW_VALIDATE
);
441 WIN_SetStyle( hwnd
, 0, WS_VISIBLE
);
446 DestroyWindow( hwnd
);
449 case WM_MOUSEACTIVATE
:
450 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)
452 LONG ret
= SendMessageW( GetParent(hwnd
), WM_MOUSEACTIVATE
, wParam
, lParam
);
456 /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
457 return (LOWORD(lParam
) >= HTCLIENT
) ? MA_ACTIVATE
: MA_NOACTIVATE
;
460 /* The default action in Windows is to set the keyboard focus to
461 * the window, if it's being activated and not minimized */
462 if (LOWORD(wParam
) != WA_INACTIVE
) {
463 if (!IsIconic(hwnd
)) SetFocus(hwnd
);
468 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)
469 return SendMessageW( GetParent(hwnd
), WM_MOUSEWHEEL
, wParam
, lParam
);
473 case WM_ICONERASEBKGND
:
476 HDC hdc
= (HDC
)wParam
;
477 HBRUSH hbr
= (HBRUSH
)GetClassLongPtrW( hwnd
, GCLP_HBRBACKGROUND
);
480 if (GetClassLongW( hwnd
, GCL_STYLE
) & CS_PARENTDC
)
482 /* can't use GetClipBox with a parent DC or we fill the whole parent */
483 GetClientRect( hwnd
, &rect
);
484 DPtoLP( hdc
, (LPPOINT
)&rect
, 2 );
486 else GetClipBox( hdc
, &rect
);
487 FillRect( hdc
, &rect
, hbr
);
494 case WM_CTLCOLORMSGBOX
:
495 case WM_CTLCOLOREDIT
:
496 case WM_CTLCOLORLISTBOX
:
499 case WM_CTLCOLORSTATIC
:
500 case WM_CTLCOLORSCROLLBAR
:
501 return (LRESULT
)DEFWND_ControlColor( (HDC
)wParam
, msg
- WM_CTLCOLORMSGBOX
);
504 return (LRESULT
)DEFWND_ControlColor( (HDC
)wParam
, HIWORD(lParam
) );
507 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)
509 /* with the exception of the border around a resizable wnd,
510 * give the parent first chance to set the cursor */
511 if ((LOWORD(lParam
) < HTSIZEFIRST
) || (LOWORD(lParam
) > HTSIZELAST
))
513 if (SendMessageW(GetParent(hwnd
), WM_SETCURSOR
, wParam
, lParam
)) return TRUE
;
516 NC_HandleSetCursor( hwnd
, wParam
, lParam
);
520 return NC_HandleSysCommand( hwnd
, wParam
, lParam
);
523 if(wParam
== VK_F10
) iF10Key
= VK_F10
;
527 if( HIWORD(lParam
) & KEYDATA_ALT
)
529 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
530 if( wParam
== VK_MENU
&& !iMenuSysKey
)
537 if( wParam
== VK_F4
) /* try to close the window */
539 HWND top
= GetAncestor( hwnd
, GA_ROOT
);
540 if (!(GetClassLongW( top
, GCL_STYLE
) & CS_NOCLOSE
))
541 PostMessageW( top
, WM_SYSCOMMAND
, SC_CLOSE
, 0 );
544 else if( wParam
== VK_F10
)
546 else if( wParam
== VK_ESCAPE
&& (GetKeyState(VK_SHIFT
) & 0x8000))
547 SendMessageW( hwnd
, WM_SYSCOMMAND
, SC_KEYMENU
, ' ' );
552 /* Press and release F10 or ALT */
553 if (((wParam
== VK_MENU
) && iMenuSysKey
) ||
554 ((wParam
== VK_F10
) && iF10Key
))
555 SendMessageW( GetAncestor( hwnd
, GA_ROOT
), WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
556 iMenuSysKey
= iF10Key
= 0;
562 if (wParam
== '\r' && IsIconic(hwnd
))
564 PostMessageW( hwnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0L );
567 if ((HIWORD(lParam
) & KEYDATA_ALT
) && wParam
)
569 if (wParam
== '\t' || wParam
== '\x1b') break;
570 if (wParam
== ' ' && (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
))
571 SendMessageW( GetParent(hwnd
), msg
, wParam
, lParam
);
573 SendMessageW( hwnd
, WM_SYSCOMMAND
, SC_KEYMENU
, wParam
);
575 else /* check for Ctrl-Esc */
576 if (wParam
!= '\x1b') MessageBeep(0);
582 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
583 if (!lParam
) return 0; /* sent from ShowWindow */
584 if (!(style
& WS_POPUP
)) return 0;
585 if ((style
& WS_VISIBLE
) && wParam
) return 0;
586 if (!(style
& WS_VISIBLE
) && !wParam
) return 0;
587 if (!GetWindow( hwnd
, GW_OWNER
)) return 0;
588 ShowWindow( hwnd
, wParam
? SW_SHOWNOACTIVATE
: SW_HIDE
);
594 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)) EndMenu();
595 if (GetCapture() == hwnd
) ReleaseCapture();
605 case WM_QUERYDROPOBJECT
:
606 return (GetWindowLongA( hwnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
) != 0;
608 case WM_QUERYDRAGICON
:
612 HICON hIcon
= (HICON
)GetClassLongPtrW( hwnd
, GCLP_HICON
);
613 HINSTANCE instance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
614 if (hIcon
) return (LRESULT
)hIcon
;
615 for(len
=1; len
<64; len
++)
616 if((hIcon
= LoadIconW(instance
, MAKEINTRESOURCEW(len
))))
617 return (LRESULT
)hIcon
;
618 return (LRESULT
)LoadIconW(0, (LPWSTR
)IDI_APPLICATION
);
622 case WM_ISACTIVEICON
:
624 WND
*wndPtr
= WIN_GetPtr( hwnd
);
625 BOOL ret
= (wndPtr
->flags
& WIN_NCACTIVATED
) != 0;
626 WIN_ReleasePtr( wndPtr
);
630 case WM_NOTIFYFORMAT
:
631 if (IsWindowUnicode(hwnd
)) return NFR_UNICODE
;
632 else return NFR_ANSI
;
635 case WM_QUERYENDSESSION
:
641 WND
*wndPtr
= WIN_GetPtr( hwnd
);
646 ret
= wndPtr
->hIconSmall
;
647 wndPtr
->hIconSmall
= (HICON
)lParam
;
651 wndPtr
->hIcon
= (HICON
)lParam
;
657 WIN_ReleasePtr( wndPtr
);
659 if (USER_Driver
.pSetWindowIcon
)
660 USER_Driver
.pSetWindowIcon( hwnd
, wParam
, (HICON
)lParam
);
662 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
| SWP_NOSIZE
|
663 SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
671 WND
*wndPtr
= WIN_GetPtr( hwnd
);
676 ret
= wndPtr
->hIconSmall
;
682 ret
= wndPtr
->hIconSmall
;
683 if (!ret
) ret
= (HICON
)GetClassLongPtrW( hwnd
, GCLP_HICONSM
);
684 /* FIXME: should have a default here if class icon is null */
690 WIN_ReleasePtr( wndPtr
);
695 SendMessageW( GetParent(hwnd
), msg
, wParam
, lParam
);
704 /***********************************************************************
705 * DefWindowProcA (USER32.@)
708 LRESULT WINAPI
DefWindowProcA( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
713 if (!(full_handle
= WIN_IsCurrentProcess( hwnd
)))
715 if (!IsWindow( hwnd
)) return 0;
716 ERR( "called for other process window %p\n", hwnd
);
721 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
727 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
728 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
729 * may have child window IDs instead of window name */
730 if (HIWORD(cs
->lpszName
))
731 DEFWND_SetTextA( hwnd
, cs
->lpszName
);
736 case WM_GETTEXTLENGTH
:
738 WND
*wndPtr
= WIN_GetPtr( hwnd
);
739 if (wndPtr
&& wndPtr
->text
)
740 result
= WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, strlenW(wndPtr
->text
),
741 NULL
, 0, NULL
, NULL
);
742 WIN_ReleasePtr( wndPtr
);
749 LPSTR dest
= (LPSTR
)lParam
;
750 WND
*wndPtr
= WIN_GetPtr( hwnd
);
755 if (!WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, -1,
756 dest
, wParam
, NULL
, NULL
)) dest
[wParam
-1] = 0;
757 result
= strlen( dest
);
760 WIN_ReleasePtr( wndPtr
);
765 DEFWND_SetTextA( hwnd
, (LPCSTR
)lParam
);
766 if( (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
767 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
768 result
= 1; /* success. FIXME: check text length */
771 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
774 CHAR chChar1
= (CHAR
)( (wParam
>>8) & 0xff );
775 CHAR chChar2
= (CHAR
)( wParam
& 0xff );
778 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar1
, lParam
);
779 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar2
, lParam
);
783 result
= SendMessageA( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
786 result
= SendMessageA( hwnd
, WM_KEYUP
, wParam
, lParam
);
789 case WM_IME_STARTCOMPOSITION
:
790 case WM_IME_COMPOSITION
:
791 case WM_IME_ENDCOMPOSITION
:
796 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
798 result
= SendMessageA( hwndIME
, msg
, wParam
, lParam
);
801 case WM_IME_SETCONTEXT
:
805 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
807 result
= DEFWND_ImmIsUIMessageA( hwndIME
, msg
, wParam
, lParam
);
811 case WM_INPUTLANGCHANGEREQUEST
:
812 /* notify about the switch only if it's really our current layout */
813 if ((HKL
)lParam
== GetKeyboardLayout(0))
814 result
= SendMessageA( hwnd
, WM_INPUTLANGCHANGE
, wParam
, lParam
);
821 BYTE ch
= LOWORD(wParam
);
823 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wch
, 1);
824 wParam
= MAKEWPARAM( wch
, HIWORD(wParam
) );
828 result
= DEFWND_DefWinProc( hwnd
, msg
, wParam
, lParam
);
832 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);
837 /***********************************************************************
838 * DefWindowProcW (USER32.@) Calls default window message handler
840 * Calls default window procedure for messages not processed
844 * Return value is dependent upon the message.
846 LRESULT WINAPI
DefWindowProcW(
847 HWND hwnd
, /* [in] window procedure receiving message */
848 UINT msg
, /* [in] message identifier */
849 WPARAM wParam
, /* [in] first message parameter */
850 LPARAM lParam
) /* [in] second message parameter */
855 if (!(full_handle
= WIN_IsCurrentProcess( hwnd
)))
857 if (!IsWindow( hwnd
)) return 0;
858 ERR( "called for other process window %p\n", hwnd
);
862 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
868 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
869 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
870 * may have child window IDs instead of window name */
871 if (HIWORD(cs
->lpszName
))
872 DEFWND_SetTextW( hwnd
, cs
->lpszName
);
877 case WM_GETTEXTLENGTH
:
879 WND
*wndPtr
= WIN_GetPtr( hwnd
);
880 if (wndPtr
&& wndPtr
->text
) result
= (LRESULT
)strlenW(wndPtr
->text
);
881 WIN_ReleasePtr( wndPtr
);
888 LPWSTR dest
= (LPWSTR
)lParam
;
889 WND
*wndPtr
= WIN_GetPtr( hwnd
);
894 lstrcpynW( dest
, wndPtr
->text
, wParam
);
895 result
= strlenW( dest
);
898 WIN_ReleasePtr( wndPtr
);
903 DEFWND_SetTextW( hwnd
, (LPCWSTR
)lParam
);
904 if( (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
905 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
906 result
= 1; /* success. FIXME: check text length */
909 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
911 SendMessageW( hwnd
, WM_CHAR
, wParam
, lParam
);
913 case WM_IME_SETCONTEXT
:
917 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
919 result
= DEFWND_ImmIsUIMessageW( hwndIME
, msg
, wParam
, lParam
);
923 case WM_IME_STARTCOMPOSITION
:
924 case WM_IME_COMPOSITION
:
925 case WM_IME_ENDCOMPOSITION
:
930 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
932 result
= SendMessageW( hwndIME
, msg
, wParam
, lParam
);
936 case WM_INPUTLANGCHANGEREQUEST
:
937 /* notify about the switch only if it's really our current layout */
938 if ((HKL
)lParam
== GetKeyboardLayout(0))
939 result
= SendMessageW( hwnd
, WM_INPUTLANGCHANGE
, wParam
, lParam
);
945 result
= DEFWND_DefWinProc( hwnd
, msg
, wParam
, lParam
);
948 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);