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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "user_private.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(win
);
28 static void default_ime_compositionW( HWND hwnd
, WPARAM wparam
, LPARAM lparam
)
34 if (!(lparam
& GCS_RESULTSTR
) || !(himc
= ImmGetContext( hwnd
))) return;
36 if ((size
= ImmGetCompositionStringW( himc
, GCS_RESULTSTR
, NULL
, 0 )))
38 if (!(buf
= HeapAlloc( GetProcessHeap(), 0, size
* sizeof(WCHAR
) ))) size
= 0;
39 else size
= ImmGetCompositionStringW( himc
, GCS_RESULTSTR
, buf
, size
* sizeof(WCHAR
) );
41 ImmReleaseContext( hwnd
, himc
);
43 for (i
= 0; i
< size
/ sizeof(WCHAR
); i
++)
44 SendMessageW( hwnd
, WM_IME_CHAR
, buf
[i
], 1 );
45 HeapFree( GetProcessHeap(), 0, buf
);
48 static void default_ime_compositionA( HWND hwnd
, WPARAM wparam
, LPARAM lparam
)
50 unsigned char lead
= 0;
55 if (!(lparam
& GCS_RESULTSTR
) || !(himc
= ImmGetContext( hwnd
))) return;
57 if ((size
= ImmGetCompositionStringA( himc
, GCS_RESULTSTR
, NULL
, 0 )))
59 if (!(buf
= HeapAlloc( GetProcessHeap(), 0, size
))) size
= 0;
60 else size
= ImmGetCompositionStringA( himc
, GCS_RESULTSTR
, buf
, size
);
62 ImmReleaseContext( hwnd
, himc
);
64 for (i
= 0; i
< size
; i
++)
66 unsigned char c
= buf
[i
];
69 if (IsDBCSLeadByte( c
)) lead
= c
;
70 else SendMessageA( hwnd
, WM_IME_CHAR
, c
, 1 );
74 SendMessageA( hwnd
, WM_IME_CHAR
, MAKEWORD(c
, lead
), 1 );
79 HeapFree( GetProcessHeap(), 0, buf
);
82 /***********************************************************************
83 * DefWindowProcA (USER32.@)
87 LRESULT WINAPI
DefWindowProcA( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
92 if (!(full_handle
= WIN_IsCurrentProcess( hwnd
)))
94 if (!IsWindow( hwnd
)) return 0;
95 ERR( "called for other process window %p\n", hwnd
);
100 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
105 result
= NC_HandleSysCommand( hwnd
, wParam
, lParam
);
109 if (HIBYTE(wParam
)) PostMessageA( hwnd
, WM_CHAR
, HIBYTE(wParam
), lParam
);
110 PostMessageA( hwnd
, WM_CHAR
, LOBYTE(wParam
), lParam
);
114 result
= PostMessageA( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
118 result
= PostMessageA( hwnd
, WM_KEYUP
, wParam
, lParam
);
121 case WM_IME_COMPOSITION
:
123 HWND ime_hwnd
= NtUserGetDefaultImeWindow( hwnd
);
124 if (!ime_hwnd
|| ime_hwnd
== NtUserGetParent( hwnd
)) break;
126 default_ime_compositionA( hwnd
, wParam
, lParam
);
131 result
= NtUserMessageCall( hwnd
, msg
, wParam
, lParam
, 0, NtUserDefWindowProc
, TRUE
);
135 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);
140 /***********************************************************************
141 * DefWindowProcW (USER32.@) Calls default window message handler
143 * Calls default window procedure for messages not processed
147 * Return value is dependent upon the message.
149 LRESULT WINAPI
DefWindowProcW(
150 HWND hwnd
, /* [in] window procedure receiving message */
151 UINT msg
, /* [in] message identifier */
152 WPARAM wParam
, /* [in] first message parameter */
153 LPARAM lParam
) /* [in] second message parameter */
158 if (!(full_handle
= WIN_IsCurrentProcess( hwnd
)))
160 if (!IsWindow( hwnd
)) return 0;
161 ERR( "called for other process window %p\n", hwnd
);
165 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
170 result
= NC_HandleSysCommand( hwnd
, wParam
, lParam
);
174 PostMessageW( hwnd
, WM_CHAR
, wParam
, lParam
);
178 result
= PostMessageW( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
182 result
= PostMessageW( hwnd
, WM_KEYUP
, wParam
, lParam
);
185 case WM_IME_COMPOSITION
:
187 HWND ime_hwnd
= NtUserGetDefaultImeWindow( hwnd
);
188 if (!ime_hwnd
|| ime_hwnd
== NtUserGetParent( hwnd
)) break;
190 default_ime_compositionW( hwnd
, wParam
, lParam
);
195 result
= NtUserMessageCall( hwnd
, msg
, wParam
, lParam
, 0, NtUserDefWindowProc
, FALSE
);
198 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);