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
);
29 /***********************************************************************
30 * DefWindowProcA (USER32.@)
34 LRESULT WINAPI
DefWindowProcA( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
39 if (!(full_handle
= WIN_IsCurrentProcess( hwnd
)))
41 if (!IsWindow( hwnd
)) return 0;
42 ERR( "called for other process window %p\n", hwnd
);
47 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
52 result
= NC_HandleSysCommand( hwnd
, wParam
, lParam
);
56 if (HIBYTE(wParam
)) PostMessageA( hwnd
, WM_CHAR
, HIBYTE(wParam
), lParam
);
57 PostMessageA( hwnd
, WM_CHAR
, LOBYTE(wParam
), lParam
);
61 result
= PostMessageA( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
65 result
= PostMessageA( hwnd
, WM_KEYUP
, wParam
, lParam
);
68 case WM_IME_COMPOSITION
:
69 if (lParam
& GCS_RESULTSTR
)
72 unsigned char lead
= 0;
74 HIMC himc
= ImmGetContext( hwnd
);
78 if ((size
= ImmGetCompositionStringA( himc
, GCS_RESULTSTR
, NULL
, 0 )))
80 if (!(buf
= HeapAlloc( GetProcessHeap(), 0, size
))) size
= 0;
81 else size
= ImmGetCompositionStringA( himc
, GCS_RESULTSTR
, buf
, size
);
83 ImmReleaseContext( hwnd
, himc
);
85 for (i
= 0; i
< size
; i
++)
87 unsigned char c
= buf
[i
];
90 if (IsDBCSLeadByte( c
))
93 SendMessageA( hwnd
, WM_IME_CHAR
, c
, 1 );
97 SendMessageA( hwnd
, WM_IME_CHAR
, MAKEWORD(c
, lead
), 1 );
101 HeapFree( GetProcessHeap(), 0, buf
);
107 result
= NtUserMessageCall( hwnd
, msg
, wParam
, lParam
, 0, NtUserDefWindowProc
, TRUE
);
111 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);
116 /***********************************************************************
117 * DefWindowProcW (USER32.@) Calls default window message handler
119 * Calls default window procedure for messages not processed
123 * Return value is dependent upon the message.
125 LRESULT WINAPI
DefWindowProcW(
126 HWND hwnd
, /* [in] window procedure receiving message */
127 UINT msg
, /* [in] message identifier */
128 WPARAM wParam
, /* [in] first message parameter */
129 LPARAM lParam
) /* [in] second message parameter */
134 if (!(full_handle
= WIN_IsCurrentProcess( hwnd
)))
136 if (!IsWindow( hwnd
)) return 0;
137 ERR( "called for other process window %p\n", hwnd
);
141 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
146 result
= NC_HandleSysCommand( hwnd
, wParam
, lParam
);
150 PostMessageW( hwnd
, WM_CHAR
, wParam
, lParam
);
154 result
= PostMessageW( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
158 result
= PostMessageW( hwnd
, WM_KEYUP
, wParam
, lParam
);
161 case WM_IME_COMPOSITION
:
162 if (lParam
& GCS_RESULTSTR
)
166 HIMC himc
= ImmGetContext( hwnd
);
170 if ((size
= ImmGetCompositionStringW( himc
, GCS_RESULTSTR
, NULL
, 0 )))
172 if (!(buf
= HeapAlloc( GetProcessHeap(), 0, size
* sizeof(WCHAR
) ))) size
= 0;
173 else size
= ImmGetCompositionStringW( himc
, GCS_RESULTSTR
, buf
, size
* sizeof(WCHAR
) );
175 ImmReleaseContext( hwnd
, himc
);
177 for (i
= 0; i
< size
/ sizeof(WCHAR
); i
++)
178 SendMessageW( hwnd
, WM_IME_CHAR
, buf
[i
], 1 );
179 HeapFree( GetProcessHeap(), 0, buf
);
185 result
= NtUserMessageCall( hwnd
, msg
, wParam
, lParam
, 0, NtUserDefWindowProc
, FALSE
);
188 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);