2 * Default window procedure
4 * Copyright 1993, 1996 Alexandre Julliard
12 #include "nonclient.h"
15 #include "debugtools.h"
20 #include "wine/unicode.h"
21 #include "wine/winuser16.h"
22 #include "wine/server.h"
25 DEFAULT_DEBUG_CHANNEL(win
);
27 /* bits in the dwKeyData */
28 #define KEYDATA_ALT 0x2000
29 #define KEYDATA_PREVSTATE 0x4000
31 static short iF10Key
= 0;
32 static short iMenuSysKey
= 0;
34 /***********************************************************************
35 * DEFWND_HandleWindowPosChanged
37 * Handle the WM_WINDOWPOSCHANGED message.
39 static void DEFWND_HandleWindowPosChanged( HWND hwnd
, UINT flags
)
42 WND
*wndPtr
= WIN_GetPtr( hwnd
);
44 rect
= wndPtr
->rectClient
;
45 WIN_ReleasePtr( wndPtr
);
47 if (!(flags
& SWP_NOCLIENTMOVE
))
48 SendMessageW( hwnd
, WM_MOVE
, 0, MAKELONG(rect
.left
, rect
.top
));
50 if (!(flags
& SWP_NOCLIENTSIZE
))
52 WPARAM wp
= SIZE_RESTORED
;
53 if (IsZoomed(hwnd
)) wp
= SIZE_MAXIMIZED
;
54 else if (IsIconic(hwnd
)) wp
= SIZE_MINIMIZED
;
56 SendMessageW( hwnd
, WM_SIZE
, wp
, MAKELONG(rect
.right
-rect
.left
, rect
.bottom
-rect
.top
) );
61 /***********************************************************************
64 * Set the window text.
66 static void DEFWND_SetTextA( HWND hwnd
, LPCSTR text
)
73 count
= MultiByteToWideChar( CP_ACP
, 0, text
, -1, NULL
, 0 );
75 if (!(wndPtr
= WIN_GetPtr( hwnd
))) return;
76 if ((textW
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(WCHAR
))))
78 if (wndPtr
->text
) HeapFree(GetProcessHeap(), 0, wndPtr
->text
);
80 MultiByteToWideChar( CP_ACP
, 0, text
, -1, textW
, count
);
81 SERVER_START_REQ( set_window_text
)
84 wine_server_add_data( req
, textW
, (count
-1) * sizeof(WCHAR
) );
85 wine_server_call( req
);
90 ERR("Not enough memory for window text\n");
91 WIN_ReleasePtr( wndPtr
);
93 if (USER_Driver
.pSetWindowText
) USER_Driver
.pSetWindowText( hwnd
, textW
);
96 /***********************************************************************
99 * Set the window text.
101 static void DEFWND_SetTextW( HWND hwnd
, LPCWSTR text
)
103 static const WCHAR empty_string
[] = {0};
107 if (!text
) text
= empty_string
;
108 count
= strlenW(text
) + 1;
110 if (!(wndPtr
= WIN_GetPtr( hwnd
))) return;
111 if (wndPtr
->text
) HeapFree(GetProcessHeap(), 0, wndPtr
->text
);
112 if ((wndPtr
->text
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(WCHAR
))))
114 strcpyW( wndPtr
->text
, text
);
115 SERVER_START_REQ( set_window_text
)
118 wine_server_add_data( req
, wndPtr
->text
, (count
-1) * sizeof(WCHAR
) );
119 wine_server_call( req
);
124 ERR("Not enough memory for window text\n");
126 WIN_ReleasePtr( wndPtr
);
128 if (USER_Driver
.pSetWindowText
) USER_Driver
.pSetWindowText( hwnd
, text
);
131 /***********************************************************************
132 * DEFWND_ControlColor
134 * Default colors for control painting.
136 HBRUSH
DEFWND_ControlColor( HDC hDC
, UINT ctlType
)
138 if( ctlType
== CTLCOLOR_SCROLLBAR
)
140 HBRUSH hb
= GetSysColorBrush(COLOR_SCROLLBAR
);
141 if (TWEAK_WineLook
== WIN31_LOOK
) {
142 SetTextColor( hDC
, RGB(0, 0, 0) );
143 SetBkColor( hDC
, RGB(255, 255, 255) );
145 COLORREF bk
= GetSysColor(COLOR_3DHILIGHT
);
146 SetTextColor( hDC
, GetSysColor(COLOR_3DFACE
));
147 SetBkColor( hDC
, bk
);
149 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
150 * we better use 0x55aa bitmap brush to make scrollbar's background
151 * look different from the window background.
153 if (bk
== GetSysColor(COLOR_WINDOW
)) {
154 return CACHE_GetPattern55AABrush();
157 UnrealizeObject( hb
);
161 SetTextColor( hDC
, GetSysColor(COLOR_WINDOWTEXT
));
163 if (TWEAK_WineLook
> WIN31_LOOK
) {
164 if ((ctlType
== CTLCOLOR_EDIT
) || (ctlType
== CTLCOLOR_LISTBOX
))
165 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
167 SetBkColor( hDC
, GetSysColor(COLOR_3DFACE
) );
168 return GetSysColorBrush(COLOR_3DFACE
);
172 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
173 return GetSysColorBrush(COLOR_WINDOW
);
177 /***********************************************************************
180 static void DEFWND_SetRedraw( HWND hwnd
, WPARAM wParam
)
182 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
183 BOOL bVisible
= wndPtr
->dwStyle
& WS_VISIBLE
;
185 TRACE("%04x %i\n", hwnd
, (wParam
!=0) );
191 WIN_SetStyle( hwnd
, wndPtr
->dwStyle
| WS_VISIBLE
);
192 DCE_InvalidateDCE( hwnd
, &wndPtr
->rectWindow
);
197 if( wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= RDW_VALIDATE
;
198 else wParam
= RDW_ALLCHILDREN
| RDW_VALIDATE
;
200 RedrawWindow( hwnd
, NULL
, 0, wParam
);
201 DCE_InvalidateDCE( hwnd
, &wndPtr
->rectWindow
);
202 WIN_SetStyle( hwnd
, wndPtr
->dwStyle
& ~WS_VISIBLE
);
204 WIN_ReleaseWndPtr( wndPtr
);
207 /***********************************************************************
210 * This method handles the default behavior for the WM_PRINT message.
212 static void DEFWND_Print( HWND hwnd
, HDC hdc
, ULONG uFlags
)
217 if ( (uFlags
& PRF_CHECKVISIBLE
) &&
218 !IsWindowVisible(hwnd
) )
222 * Unimplemented flags.
224 if ( (uFlags
& PRF_CHILDREN
) ||
225 (uFlags
& PRF_OWNED
) ||
226 (uFlags
& PRF_NONCLIENT
) )
228 WARN("WM_PRINT message with unsupported flags\n");
234 if ( uFlags
& PRF_ERASEBKGND
)
235 SendMessageW(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
240 if ( uFlags
& PRF_CLIENT
)
241 SendMessageW(hwnd
, WM_PRINTCLIENT
, (WPARAM
)hdc
, PRF_CLIENT
);
246 * helpers for calling IMM32
248 * WM_IME_* messages are generated only by IMM32,
249 * so I assume imm32 is already LoadLibrary-ed.
251 static HWND
DEFWND_ImmGetDefaultIMEWnd( HWND hwnd
)
253 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
254 HWND (WINAPI
*pFunc
)(HWND
);
259 ERR( "cannot get IMM32 handle\n" );
263 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmGetDefaultIMEWnd");
265 hwndRet
= (*pFunc
)( hwnd
);
270 static BOOL
DEFWND_ImmIsUIMessageA( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
272 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
273 BOOL (WINAPI
*pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
278 ERR( "cannot get IMM32 handle\n" );
282 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageA");
284 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
289 static BOOL
DEFWND_ImmIsUIMessageW( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
291 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
292 BOOL (WINAPI
*pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
297 ERR( "cannot get IMM32 handle\n" );
301 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageW");
303 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
310 /***********************************************************************
313 * Default window procedure for messages that are the same in Win16 and Win32.
315 static LRESULT
DEFWND_DefWinProc( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
320 return NC_HandleNCPaint( hwnd
, (HRGN
)wParam
);
325 pt
.x
= SLOWORD(lParam
);
326 pt
.y
= SHIWORD(lParam
);
327 return NC_HandleNCHitTest( hwnd
, pt
);
330 case WM_NCLBUTTONDOWN
:
331 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
333 case WM_LBUTTONDBLCLK
:
334 case WM_NCLBUTTONDBLCLK
:
335 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
337 case WM_NCRBUTTONDOWN
:
338 /* in Windows, capture is taken when right-clicking on the caption bar */
339 if (wParam
==HTCAPTION
)
349 if (hwnd
== GetCapture())
350 /* release capture if we took it on WM_NCRBUTTONDOWN */
353 pt
.x
= SLOWORD(lParam
);
354 pt
.y
= SHIWORD(lParam
);
355 ClientToScreen(hwnd
, &pt
);
356 SendMessageW( hwnd
, WM_CONTEXTMENU
, (WPARAM
)hwnd
, MAKELPARAM(pt
.x
, pt
.y
) );
362 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
363 * in Windows), but what _should_ we do? According to MSDN :
364 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
365 * message to the window". When is it appropriate?
370 if (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)
371 SendMessageW( GetParent(hwnd
), msg
, wParam
, lParam
);
376 WND
*wndPtr
= WIN_GetPtr( hwnd
);
377 HMENU hMenu
= wndPtr
->hSysMenu
;
378 WIN_ReleasePtr( wndPtr
);
379 if (!hMenu
) return 0;
380 pt
.x
= SLOWORD(lParam
);
381 pt
.y
= SHIWORD(lParam
);
382 hitcode
= NC_HandleNCHitTest(hwnd
, pt
);
384 /* Track system popup if click was in the caption area. */
385 if (hitcode
==HTCAPTION
|| hitcode
==HTSYSMENU
)
386 TrackPopupMenu(GetSystemMenu(hwnd
, FALSE
),
387 TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
,
388 pt
.x
, pt
.y
, 0, hwnd
, NULL
);
393 return NC_HandleNCActivate( hwnd
, wParam
);
397 WND
*wndPtr
= WIN_GetPtr( hwnd
);
398 if (!wndPtr
) return 0;
399 if (wndPtr
->text
) HeapFree( GetProcessHeap(), 0, wndPtr
->text
);
401 if (wndPtr
->pVScroll
) HeapFree( GetProcessHeap(), 0, wndPtr
->pVScroll
);
402 if (wndPtr
->pHScroll
) HeapFree( GetProcessHeap(), 0, wndPtr
->pHScroll
);
403 wndPtr
->pVScroll
= wndPtr
->pHScroll
= NULL
;
404 WIN_ReleasePtr( wndPtr
);
409 DEFWND_Print(hwnd
, (HDC
)wParam
, lParam
);
416 HDC hdc
= BeginPaint( hwnd
, &ps
);
420 if (IsIconic(hwnd
) && ((hIcon
= GetClassLongW( hwnd
, GCL_HICON
))) )
425 GetClientRect( hwnd
, &rc
);
426 x
= (rc
.right
- rc
.left
- GetSystemMetrics(SM_CXICON
))/2;
427 y
= (rc
.bottom
- rc
.top
- GetSystemMetrics(SM_CYICON
))/2;
428 TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
429 ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
430 DrawIcon( hdc
, x
, y
, hIcon
);
432 EndPaint( hwnd
, &ps
);
438 RedrawWindow ( hwnd
, NULL
, 0, RDW_ERASENOW
| RDW_ERASE
| RDW_ALLCHILDREN
);
442 DEFWND_SetRedraw( hwnd
, wParam
);
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
= GetClassLongW( hwnd
, GCL_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 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
519 return NC_HandleSysCommand( hwnd
, wParam
, lParam
);
522 if(wParam
== VK_F10
) iF10Key
= VK_F10
;
526 if( HIWORD(lParam
) & KEYDATA_ALT
)
528 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
529 if( wParam
== VK_MENU
&& !iMenuSysKey
)
536 if( wParam
== VK_F4
) /* try to close the window */
538 HWND top
= GetAncestor( hwnd
, GA_ROOT
);
539 if (!(GetClassLongW( top
, GCL_STYLE
) & CS_NOCLOSE
))
540 PostMessageW( top
, WM_SYSCOMMAND
, SC_CLOSE
, 0 );
543 else if( wParam
== VK_F10
)
546 if( wParam
== VK_ESCAPE
&& (GetKeyState(VK_SHIFT
) & 0x8000))
547 SendMessageW( hwnd
, WM_SYSCOMMAND
, SC_KEYMENU
, VK_SPACE
);
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;
561 if (wParam
== VK_RETURN
&& IsIconic(hwnd
))
563 PostMessageW( hwnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0L );
566 if ((HIWORD(lParam
) & KEYDATA_ALT
) && wParam
)
568 if (wParam
== VK_TAB
|| wParam
== VK_ESCAPE
) break;
569 if (wParam
== VK_SPACE
&& (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
))
570 SendMessageW( GetParent(hwnd
), msg
, wParam
, lParam
);
572 SendMessageW( hwnd
, WM_SYSCOMMAND
, SC_KEYMENU
, wParam
);
574 else /* check for Ctrl-Esc */
575 if (wParam
!= VK_ESCAPE
) MessageBeep(0);
580 LONG style
= GetWindowLongW( hwnd
, GWL_STYLE
);
581 if (!lParam
) return 0; /* sent from ShowWindow */
582 if (!(style
& WS_POPUP
)) return 0;
583 if ((style
& WS_VISIBLE
) && wParam
) return 0;
584 if (!(style
& WS_VISIBLE
) && !wParam
) return 0;
585 if (!GetWindow( hwnd
, GW_OWNER
)) return 0;
586 ShowWindow( hwnd
, wParam
? SW_SHOWNOACTIVATE
: SW_HIDE
);
591 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)) EndMenu();
592 if (GetCapture() == hwnd
) ReleaseCapture();
602 case WM_QUERYDROPOBJECT
:
603 return (GetWindowLongA( hwnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
) != 0;
605 case WM_QUERYDRAGICON
:
609 HICON hIcon
= GetClassLongW( hwnd
, GCL_HICON
);
610 HINSTANCE instance
= GetWindowLongW( hwnd
, GWL_HINSTANCE
);
611 if (hIcon
) return hIcon
;
612 for(len
=1; len
<64; len
++)
613 if((hIcon
= LoadIconW(instance
, MAKEINTRESOURCEW(len
))))
614 return (LRESULT
)hIcon
;
615 return (LRESULT
)LoadIconW(0, IDI_APPLICATIONW
);
619 case WM_ISACTIVEICON
:
621 WND
*wndPtr
= WIN_GetPtr( hwnd
);
622 BOOL ret
= (wndPtr
->flags
& WIN_NCACTIVATED
) != 0;
623 WIN_ReleasePtr( wndPtr
);
627 case WM_NOTIFYFORMAT
:
628 if (IsWindowUnicode(hwnd
)) return NFR_UNICODE
;
629 else return NFR_ANSI
;
632 case WM_QUERYENDSESSION
:
636 if (USER_Driver
.pSetWindowIcon
)
637 return USER_Driver
.pSetWindowIcon( hwnd
, lParam
, (wParam
!= ICON_SMALL
) );
640 HICON hOldIcon
= SetClassLongW( hwnd
, (wParam
!= ICON_SMALL
) ? GCL_HICON
: GCL_HICONSM
,
642 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
| SWP_NOSIZE
|
643 SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
648 return GetClassLongW( hwnd
, (wParam
!= ICON_SMALL
) ? GCL_HICON
: GCL_HICONSM
);
651 SendMessageW( GetParent(hwnd
), msg
, wParam
, lParam
);
660 /***********************************************************************
661 * DefWindowProc (USER.107)
663 LRESULT WINAPI
DefWindowProc16( HWND16 hwnd16
, UINT16 msg
, WPARAM16 wParam
,
667 HWND hwnd
= WIN_Handle32( hwnd16
);
669 if (!WIN_IsCurrentProcess( hwnd
))
671 if (!IsWindow( hwnd
)) return 0;
672 ERR( "called for other process window %x\n", hwnd
);
675 SPY_EnterMessage( SPY_DEFWNDPROC16
, hwnd
, msg
, wParam
, lParam
);
681 CREATESTRUCT16
*cs
= MapSL(lParam
);
682 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
683 * may have child window IDs instead of window name */
684 if (HIWORD(cs
->lpszName
))
685 DEFWND_SetTextA( hwnd
, MapSL(cs
->lpszName
) );
693 CONV_RECT16TO32( MapSL(lParam
), &rect32
);
694 result
= NC_HandleNCCalcSize( hwnd
, &rect32
);
695 CONV_RECT32TO16( &rect32
, MapSL(lParam
) );
699 case WM_WINDOWPOSCHANGING
:
700 result
= WINPOS_HandleWindowPosChanging16( hwnd
, MapSL(lParam
) );
703 case WM_WINDOWPOSCHANGED
:
705 WINDOWPOS16
* winPos
= MapSL(lParam
);
706 DEFWND_HandleWindowPosChanged( hwnd
, winPos
->flags
);
712 result
= DefWindowProcA( hwnd
, msg
, wParam
, (LPARAM
)MapSL(lParam
) );
716 result
= DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
720 SPY_ExitMessage( SPY_RESULT_DEFWND16
, hwnd
, msg
, result
, wParam
, lParam
);
725 /***********************************************************************
726 * DefWindowProcA (USER32.@)
729 LRESULT WINAPI
DefWindowProcA( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
734 if (!(full_handle
= WIN_IsCurrentProcess( hwnd
)))
736 if (!IsWindow( hwnd
)) return 0;
737 ERR( "called for other process window %x\n", hwnd
);
742 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
748 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
749 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
750 * may have child window IDs instead of window name */
751 if (HIWORD(cs
->lpszName
))
752 DEFWND_SetTextA( hwnd
, cs
->lpszName
);
758 result
= NC_HandleNCCalcSize( hwnd
, (RECT
*)lParam
);
761 case WM_WINDOWPOSCHANGING
:
762 result
= WINPOS_HandleWindowPosChanging( hwnd
, (WINDOWPOS
*)lParam
);
765 case WM_WINDOWPOSCHANGED
:
767 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
768 DEFWND_HandleWindowPosChanged( hwnd
, winPos
->flags
);
772 case WM_GETTEXTLENGTH
:
774 WND
*wndPtr
= WIN_GetPtr( hwnd
);
775 if (wndPtr
&& wndPtr
->text
)
776 result
= WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, strlenW(wndPtr
->text
),
777 NULL
, 0, NULL
, NULL
);
778 WIN_ReleasePtr( wndPtr
);
784 WND
*wndPtr
= WIN_GetPtr( hwnd
);
785 if (wParam
&& wndPtr
&& wndPtr
->text
)
787 LPSTR dest
= (LPSTR
)lParam
;
788 if (!WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, -1,
789 dest
, wParam
, NULL
, NULL
)) dest
[wParam
-1] = 0;
790 result
= strlen( dest
);
792 WIN_ReleasePtr( wndPtr
);
797 DEFWND_SetTextA( hwnd
, (LPCSTR
)lParam
);
798 if( (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
799 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
800 result
= 1; /* success. FIXME: check text length */
803 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
806 CHAR chChar1
= (CHAR
)( (wParam
>>8) & 0xff );
807 CHAR chChar2
= (CHAR
)( wParam
& 0xff );
809 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar1
, lParam
);
810 if ( IsDBCSLeadByte( chChar1
) )
811 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar2
, lParam
);
815 result
= SendMessageA( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
818 result
= SendMessageA( hwnd
, WM_KEYUP
, wParam
, lParam
);
821 case WM_IME_STARTCOMPOSITION
:
822 case WM_IME_COMPOSITION
:
823 case WM_IME_ENDCOMPOSITION
:
828 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
830 result
= SendMessageA( hwndIME
, msg
, wParam
, lParam
);
833 case WM_IME_SETCONTEXT
:
837 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
839 result
= DEFWND_ImmIsUIMessageA( hwndIME
, msg
, wParam
, lParam
);
844 result
= DEFWND_DefWinProc( hwnd
, msg
, wParam
, lParam
);
848 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);
853 /***********************************************************************
854 * DefWindowProcW (USER32.@) Calls default window message handler
856 * Calls default window procedure for messages not processed
860 * Return value is dependent upon the message.
862 LRESULT WINAPI
DefWindowProcW(
863 HWND hwnd
, /* [in] window procedure receiving message */
864 UINT msg
, /* [in] message identifier */
865 WPARAM wParam
, /* [in] first message parameter */
866 LPARAM lParam
) /* [in] second message parameter */
871 if (!(full_handle
= WIN_IsCurrentProcess( hwnd
)))
873 if (!IsWindow( hwnd
)) return 0;
874 ERR( "called for other process window %x\n", hwnd
);
878 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
884 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
885 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
886 * may have child window IDs instead of window name */
887 if (HIWORD(cs
->lpszName
))
888 DEFWND_SetTextW( hwnd
, cs
->lpszName
);
894 result
= NC_HandleNCCalcSize( hwnd
, (RECT
*)lParam
);
897 case WM_WINDOWPOSCHANGING
:
898 result
= WINPOS_HandleWindowPosChanging( hwnd
, (WINDOWPOS
*)lParam
);
901 case WM_WINDOWPOSCHANGED
:
903 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
904 DEFWND_HandleWindowPosChanged( hwnd
, winPos
->flags
);
908 case WM_GETTEXTLENGTH
:
910 WND
*wndPtr
= WIN_GetPtr( hwnd
);
911 if (wndPtr
&& wndPtr
->text
) result
= (LRESULT
)strlenW(wndPtr
->text
);
912 WIN_ReleasePtr( wndPtr
);
918 WND
*wndPtr
= WIN_GetPtr( hwnd
);
919 if (wParam
&& wndPtr
&& wndPtr
->text
)
921 LPWSTR dest
= (LPWSTR
)lParam
;
922 lstrcpynW( dest
, wndPtr
->text
, wParam
);
923 result
= strlenW( dest
);
925 WIN_ReleasePtr( wndPtr
);
930 DEFWND_SetTextW( hwnd
, (LPCWSTR
)lParam
);
931 if( (GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CAPTION
) == WS_CAPTION
)
932 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
933 result
= 1; /* success. FIXME: check text length */
936 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
938 SendMessageW( hwnd
, WM_CHAR
, wParam
, lParam
);
940 case WM_IME_SETCONTEXT
:
944 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
946 result
= DEFWND_ImmIsUIMessageW( hwndIME
, msg
, wParam
, lParam
);
951 result
= DEFWND_DefWinProc( hwnd
, msg
, wParam
, lParam
);
954 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);