2 * Default window procedure
4 * Copyright 1993, 1996 Alexandre Julliard
13 #include "nonclient.h"
16 #include "debugtools.h"
23 #include "wine/unicode.h"
24 #include "wine/winuser16.h"
27 DEFAULT_DEBUG_CHANNEL(win
);
29 /* bits in the dwKeyData */
30 #define KEYDATA_ALT 0x2000
31 #define KEYDATA_PREVSTATE 0x4000
33 static short iF10Key
= 0;
34 static short iMenuSysKey
= 0;
36 /***********************************************************************
37 * DEFWND_HandleWindowPosChanged
39 * Handle the WM_WINDOWPOSCHANGED message.
41 static void DEFWND_HandleWindowPosChanged( WND
*wndPtr
, UINT flags
)
43 WPARAM16 wp
= SIZE_RESTORED
;
45 if (!(flags
& SWP_NOCLIENTMOVE
))
46 SendMessage16( wndPtr
->hwndSelf
, WM_MOVE
, 0,
47 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
));
48 if (!(flags
& SWP_NOCLIENTSIZE
))
50 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wp
= SIZE_MAXIMIZED
;
51 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wp
= SIZE_MINIMIZED
;
53 SendMessage16( wndPtr
->hwndSelf
, WM_SIZE
, wp
,
54 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
55 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
60 /***********************************************************************
63 * Set the window text.
65 void DEFWND_SetTextA( WND
*wndPtr
, LPCSTR text
)
70 count
= MultiByteToWideChar( CP_ACP
, 0, text
, -1, NULL
, 0 );
72 if (wndPtr
->text
) HeapFree(SystemHeap
, 0, wndPtr
->text
);
73 if ((wndPtr
->text
= HeapAlloc(SystemHeap
, 0, count
* sizeof(WCHAR
))))
74 MultiByteToWideChar( CP_ACP
, 0, text
, -1, wndPtr
->text
, count
);
76 ERR("Not enough memory for window text");
78 wndPtr
->pDriver
->pSetText(wndPtr
, wndPtr
->text
);
81 /***********************************************************************
84 * Set the window text.
86 void DEFWND_SetTextW( WND
*wndPtr
, LPCWSTR text
)
88 static const WCHAR empty_string
[] = {0};
91 if (!text
) text
= empty_string
;
92 count
= strlenW(text
) + 1;
94 if (wndPtr
->text
) HeapFree(SystemHeap
, 0, wndPtr
->text
);
95 if ((wndPtr
->text
= HeapAlloc(SystemHeap
, 0, count
* sizeof(WCHAR
))))
96 strcpyW( wndPtr
->text
, text
);
98 ERR("Not enough memory for window text");
100 wndPtr
->pDriver
->pSetText(wndPtr
, wndPtr
->text
);
103 /***********************************************************************
104 * DEFWND_ControlColor
106 * Default colors for control painting.
108 HBRUSH
DEFWND_ControlColor( HDC hDC
, UINT16 ctlType
)
110 if( ctlType
== CTLCOLOR_SCROLLBAR
)
112 HBRUSH hb
= GetSysColorBrush(COLOR_SCROLLBAR
);
113 if (TWEAK_WineLook
== WIN31_LOOK
) {
114 SetTextColor( hDC
, RGB(0, 0, 0) );
115 SetBkColor( hDC
, RGB(255, 255, 255) );
117 COLORREF bk
= GetSysColor(COLOR_3DHILIGHT
);
118 SetTextColor( hDC
, GetSysColor(COLOR_3DFACE
));
119 SetBkColor( hDC
, bk
);
121 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
122 * we better use 0x55aa bitmap brush to make scrollbar's background
123 * look different from the window background.
125 if (bk
== GetSysColor(COLOR_WINDOW
)) {
126 return CACHE_GetPattern55AABrush();
129 UnrealizeObject( hb
);
133 SetTextColor( hDC
, GetSysColor(COLOR_WINDOWTEXT
));
135 if (TWEAK_WineLook
> WIN31_LOOK
) {
136 if ((ctlType
== CTLCOLOR_EDIT
) || (ctlType
== CTLCOLOR_LISTBOX
))
137 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
139 SetBkColor( hDC
, GetSysColor(COLOR_3DFACE
) );
140 return GetSysColorBrush(COLOR_3DFACE
);
144 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
145 return GetSysColorBrush(COLOR_WINDOW
);
149 /***********************************************************************
152 static void DEFWND_SetRedraw( WND
* wndPtr
, WPARAM wParam
)
154 BOOL bVisible
= wndPtr
->dwStyle
& WS_VISIBLE
;
156 TRACE("%04x %i\n", wndPtr
->hwndSelf
, (wParam
!=0) );
162 wndPtr
->dwStyle
|= WS_VISIBLE
;
163 DCE_InvalidateDCE( wndPtr
, &wndPtr
->rectWindow
);
168 if( wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= RDW_VALIDATE
;
169 else wParam
= RDW_ALLCHILDREN
| RDW_VALIDATE
;
171 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, wParam
, 0 );
172 DCE_InvalidateDCE( wndPtr
, &wndPtr
->rectWindow
);
173 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
177 /***********************************************************************
180 * This method handles the default behavior for the WM_PRINT message.
182 static void DEFWND_Print(
190 if ( (uFlags
& PRF_CHECKVISIBLE
) &&
191 !IsWindowVisible(wndPtr
->hwndSelf
) )
195 * Unimplemented flags.
197 if ( (uFlags
& PRF_CHILDREN
) ||
198 (uFlags
& PRF_OWNED
) ||
199 (uFlags
& PRF_NONCLIENT
) )
201 WARN("WM_PRINT message with unsupported flags\n");
207 if ( uFlags
& PRF_ERASEBKGND
)
208 SendMessageA(wndPtr
->hwndSelf
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
213 if ( uFlags
& PRF_CLIENT
)
214 SendMessageA(wndPtr
->hwndSelf
, WM_PRINTCLIENT
, (WPARAM
)hdc
, PRF_CLIENT
);
219 * helpers for calling IMM32
221 * WM_IME_* messages are generated only by IMM32,
222 * so I assume imm32 is already LoadLibrary-ed.
224 static HWND
DEFWND_ImmGetDefaultIMEWnd( HWND hwnd
)
226 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
227 HWND (WINAPI
* pFunc
)(HWND
);
232 ERR( "cannot get IMM32 handle\n" );
236 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmGetDefaultIMEWnd");
238 hwndRet
= (*pFunc
)( hwnd
);
243 static BOOL
DEFWND_ImmIsUIMessageA( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
245 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
246 BOOL (WINAPI
* pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
251 ERR( "cannot get IMM32 handle\n" );
255 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageA");
257 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
262 static BOOL
DEFWND_ImmIsUIMessageW( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
264 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
265 BOOL (WINAPI
* pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
270 ERR( "cannot get IMM32 handle\n" );
274 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageW");
276 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
283 /***********************************************************************
286 * Default window procedure for messages that are the same in Win16 and Win32.
288 static LRESULT
DEFWND_DefWinProc( WND
*wndPtr
, UINT msg
, WPARAM wParam
,
294 return NC_HandleNCPaint( wndPtr
->hwndSelf
, (HRGN
)wParam
);
299 pt
.x
= SLOWORD(lParam
);
300 pt
.y
= SHIWORD(lParam
);
301 return NC_HandleNCHitTest( wndPtr
->hwndSelf
, pt
);
304 case WM_NCLBUTTONDOWN
:
305 return NC_HandleNCLButtonDown( wndPtr
, wParam
, lParam
);
307 case WM_LBUTTONDBLCLK
:
308 case WM_NCLBUTTONDBLCLK
:
309 return NC_HandleNCLButtonDblClk( wndPtr
, wParam
, lParam
);
311 case WM_NCRBUTTONDOWN
:
312 /* in Windows, capture is taken when right-clicking on the caption bar */
313 if (wParam
==HTCAPTION
)
315 SetCapture(wndPtr
->hwndSelf
);
320 if (wndPtr
->hwndSelf
== GetCapture())
322 /* release capture if we took it on WM_NCRBUTTONDOWN */
325 if ((wndPtr
->flags
& WIN_ISWIN32
) || (TWEAK_WineLook
> WIN31_LOOK
))
327 ClientToScreen16(wndPtr
->hwndSelf
, (LPPOINT16
)&lParam
);
328 SendMessageA( wndPtr
->hwndSelf
, WM_CONTEXTMENU
,
329 wndPtr
->hwndSelf
, lParam
);
335 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
336 * in Windows), but what _should_ we do? According to MSDN :
337 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
338 * message to the window". When is it appropriate?
343 if( wndPtr
->dwStyle
& WS_CHILD
)
344 SendMessageA( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
345 else if (wndPtr
->hSysMenu
)
349 pt
.x
= SLOWORD(lParam
);
350 pt
.y
= SHIWORD(lParam
);
353 * WM_CONTEXTMENU coordinates are relative to screen, but
354 * NC_HandleNCHitTest expects coordinates relative to the parent's
355 * client area (to compare with the rectangle returned by
359 ScreenToClient(wndPtr
->parent
->hwndSelf
, &pt
);
361 hitcode
= NC_HandleNCHitTest(wndPtr
->hwndSelf
, pt
);
363 /* Track system popup if click was in the caption area. */
364 if (hitcode
==HTCAPTION
|| hitcode
==HTSYSMENU
)
365 TrackPopupMenu(GetSystemMenu(wndPtr
->hwndSelf
, FALSE
),
366 TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
,
367 pt
.x
, pt
.y
, 0, wndPtr
->hwndSelf
, NULL
);
372 return NC_HandleNCActivate( wndPtr
, wParam
);
375 if (wndPtr
->text
) HeapFree( SystemHeap
, 0, wndPtr
->text
);
377 if (wndPtr
->pVScroll
) HeapFree( SystemHeap
, 0, wndPtr
->pVScroll
);
378 if (wndPtr
->pHScroll
) HeapFree( SystemHeap
, 0, wndPtr
->pHScroll
);
379 wndPtr
->pVScroll
= wndPtr
->pHScroll
= NULL
;
383 DEFWND_Print(wndPtr
, (HDC
)wParam
, lParam
);
390 HDC16 hdc
= BeginPaint16( wndPtr
->hwndSelf
, &ps
);
394 if( (wndPtr
->dwStyle
& WS_MINIMIZE
) && ((hIcon
= GetClassLongA( wndPtr
->hwndSelf
, GCL_HICON
))) )
396 int x
= (wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
-
397 GetSystemMetrics(SM_CXICON
))/2;
398 int y
= (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
-
399 GetSystemMetrics(SM_CYICON
))/2;
400 TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
401 ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
402 DrawIcon( hdc
, x
, y
, hIcon
);
404 EndPaint16( wndPtr
->hwndSelf
, &ps
);
410 if (wndPtr
->hrgnUpdate
)
412 RedrawWindow ( wndPtr
->hwndSelf
, 0, wndPtr
->hrgnUpdate
,
413 RDW_ERASENOW
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
418 DEFWND_SetRedraw( wndPtr
, wParam
);
422 DestroyWindow( wndPtr
->hwndSelf
);
425 case WM_MOUSEACTIVATE
:
426 if (wndPtr
->dwStyle
& WS_CHILD
)
428 LONG ret
= SendMessage16( wndPtr
->parent
->hwndSelf
,
429 WM_MOUSEACTIVATE
, wParam
, lParam
);
433 /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
434 return (LOWORD(lParam
) >= HTCLIENT
) ? MA_ACTIVATE
: MA_NOACTIVATE
;
437 /* The default action in Windows is to set the keyboard focus to
438 * the window, if it's being activated and not minimized */
439 if (LOWORD(wParam
) != WA_INACTIVE
) {
440 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
441 SetFocus(wndPtr
->hwndSelf
);
446 if (wndPtr
->dwStyle
& WS_CHILD
)
448 return SendMessageA( wndPtr
->parent
->hwndSelf
,
449 WM_MOUSEWHEEL
, wParam
, lParam
);
454 case WM_ICONERASEBKGND
:
457 HBRUSH hbr
= GetClassLongA( wndPtr
->hwndSelf
, GCL_HBRBACKGROUND
);
460 /* Since WM_ERASEBKGND may receive either a window dc or a */
461 /* client dc, the area to be erased has to be retrieved from */
462 /* the device context. */
463 GetClipBox( (HDC
)wParam
, &rect
);
465 /* Always call the Win32 variant of FillRect even on Win16,
466 * since despite the fact that Win16, as well as Win32,
467 * supports special background brushes for a window class,
468 * the Win16 variant of FillRect does not.
470 FillRect( (HDC
) wParam
, &rect
, hbr
);
477 case WM_CTLCOLORMSGBOX
:
478 case WM_CTLCOLOREDIT
:
479 case WM_CTLCOLORLISTBOX
:
482 case WM_CTLCOLORSTATIC
:
483 case WM_CTLCOLORSCROLLBAR
:
484 return (LRESULT
)DEFWND_ControlColor( (HDC
)wParam
, msg
- WM_CTLCOLORMSGBOX
);
487 return (LRESULT
)DEFWND_ControlColor( (HDC
)wParam
, HIWORD(lParam
) );
489 case WM_GETTEXTLENGTH
:
490 if (wndPtr
->text
) return (LRESULT
)strlenW(wndPtr
->text
);
494 if (wndPtr
->dwStyle
& WS_CHILD
)
495 if (SendMessage16(wndPtr
->parent
->hwndSelf
, WM_SETCURSOR
,
498 return NC_HandleSetCursor( wndPtr
->hwndSelf
, wParam
, lParam
);
503 pt
.x
= SLOWORD(lParam
);
504 pt
.y
= SHIWORD(lParam
);
505 return NC_HandleSysCommand( wndPtr
->hwndSelf
, wParam
, pt
);
509 if(wParam
== VK_F10
) iF10Key
= VK_F10
;
513 if( HIWORD(lParam
) & KEYDATA_ALT
)
515 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
516 if( wParam
== VK_MENU
&& !iMenuSysKey
)
523 if( wParam
== VK_F4
) /* try to close the window */
525 HWND hWnd
= WIN_GetTopParent( wndPtr
->hwndSelf
);
526 wndPtr
= WIN_FindWndPtr( hWnd
);
527 if( wndPtr
&& !(wndPtr
->clsStyle
& CS_NOCLOSE
) )
528 PostMessage16( hWnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0 );
529 WIN_ReleaseWndPtr(wndPtr
);
532 else if( wParam
== VK_F10
)
535 if( wParam
== VK_ESCAPE
&& (GetKeyState(VK_SHIFT
) & 0x8000))
536 SendMessage16( wndPtr
->hwndSelf
, WM_SYSCOMMAND
,
537 (WPARAM16
)SC_KEYMENU
, (LPARAM
)VK_SPACE
);
542 /* Press and release F10 or ALT */
543 if (((wParam
== VK_MENU
) && iMenuSysKey
) ||
544 ((wParam
== VK_F10
) && iF10Key
))
545 SendMessage16( WIN_GetTopParent(wndPtr
->hwndSelf
),
546 WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
547 iMenuSysKey
= iF10Key
= 0;
552 if (wParam
== VK_RETURN
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))
554 PostMessage16( wndPtr
->hwndSelf
, WM_SYSCOMMAND
,
555 (WPARAM16
)SC_RESTORE
, 0L );
558 if ((HIWORD(lParam
) & KEYDATA_ALT
) && wParam
)
560 if (wParam
== VK_TAB
|| wParam
== VK_ESCAPE
) break;
561 if (wParam
== VK_SPACE
&& (wndPtr
->dwStyle
& WS_CHILD
))
562 SendMessage16( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
564 SendMessage16( wndPtr
->hwndSelf
, WM_SYSCOMMAND
,
565 (WPARAM16
)SC_KEYMENU
, (LPARAM
)(DWORD
)wParam
);
567 else /* check for Ctrl-Esc */
568 if (wParam
!= VK_ESCAPE
) MessageBeep(0);
572 if (!lParam
) return 0; /* sent from ShowWindow */
573 if (!(wndPtr
->dwStyle
& WS_POPUP
) || !wndPtr
->owner
) return 0;
574 if ((wndPtr
->dwStyle
& WS_VISIBLE
) && wParam
) return 0;
575 else if (!(wndPtr
->dwStyle
& WS_VISIBLE
) && !wParam
) return 0;
576 ShowWindow( wndPtr
->hwndSelf
, wParam
? SW_SHOWNOACTIVATE
: SW_HIDE
);
580 if (wndPtr
->parent
== WIN_GetDesktop()) EndMenu();
581 if (GetCapture() == wndPtr
->hwndSelf
) ReleaseCapture();
582 WIN_ReleaseDesktop();
592 case WM_QUERYDROPOBJECT
:
593 if (wndPtr
->dwExStyle
& WS_EX_ACCEPTFILES
) return 1;
596 case WM_QUERYDRAGICON
:
600 HICON hIcon
= GetClassLongA( wndPtr
->hwndSelf
, GCL_HICON
);
601 if (hIcon
) return hIcon
;
602 for(len
=1; len
<64; len
++)
603 if((hIcon
=LoadIconA(wndPtr
->hInstance
,MAKEINTRESOURCEA(len
))))
604 return (LRESULT
)hIcon
;
605 return (LRESULT
)LoadIconA(0,IDI_APPLICATIONA
);
609 case WM_ISACTIVEICON
:
610 return ((wndPtr
->flags
& WIN_NCACTIVATED
) != 0);
612 case WM_NOTIFYFORMAT
:
613 if (IsWindowUnicode(wndPtr
->hwndSelf
)) return NFR_UNICODE
;
614 else return NFR_ANSI
;
617 case WM_QUERYENDSESSION
:
622 int index
= (wParam
!= ICON_SMALL
) ? GCL_HICON
: GCL_HICONSM
;
623 HICON16 hOldIcon
= GetClassLongA(wndPtr
->hwndSelf
, index
);
624 SetClassLongA(wndPtr
->hwndSelf
, index
, lParam
);
626 SetWindowPos(wndPtr
->hwndSelf
, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
627 | SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
630 if( wndPtr
->flags
& WIN_NATIVE
)
631 wndPtr
->pDriver
->pSetHostAttr(wndPtr
, HAK_ICONS
, 0);
638 int index
= (wParam
!= ICON_SMALL
) ? GCL_HICON
: GCL_HICONSM
;
639 return GetClassLongA(wndPtr
->hwndSelf
, index
);
643 SendMessageA( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
652 /***********************************************************************
653 * DefWindowProc (USER.107)
655 LRESULT WINAPI
DefWindowProc16( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
,
658 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
661 if (!wndPtr
) return 0;
662 SPY_EnterMessage( SPY_DEFWNDPROC16
, hwnd
, msg
, wParam
, lParam
);
668 CREATESTRUCT16
*cs
= MapSL(lParam
);
670 DEFWND_SetTextA( wndPtr
, MapSL(cs
->lpszName
) );
678 CONV_RECT16TO32( MapSL(lParam
), &rect32
);
679 result
= NC_HandleNCCalcSize( wndPtr
, &rect32
);
680 CONV_RECT32TO16( &rect32
, MapSL(lParam
) );
684 case WM_WINDOWPOSCHANGING
:
685 result
= WINPOS_HandleWindowPosChanging16( wndPtr
, MapSL(lParam
) );
688 case WM_WINDOWPOSCHANGED
:
690 WINDOWPOS16
* winPos
= MapSL(lParam
);
691 DEFWND_HandleWindowPosChanged( wndPtr
, winPos
->flags
);
696 if (wParam
&& wndPtr
->text
)
698 LPSTR dest
= MapSL(lParam
);
699 if (!WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, -1, dest
, wParam
, NULL
, NULL
))
701 result
= strlen(dest
);
706 DEFWND_SetTextA( wndPtr
, MapSL(lParam
) );
707 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
708 NC_HandleNCPaint( hwnd
, (HRGN
)1 );
709 result
= 1; /* success. FIXME: check text length */
713 result
= DEFWND_DefWinProc( wndPtr
, msg
, wParam
, lParam
);
717 WIN_ReleaseWndPtr(wndPtr
);
718 SPY_ExitMessage( SPY_RESULT_DEFWND16
, hwnd
, msg
, result
, wParam
, lParam
);
723 /***********************************************************************
724 * DefWindowProcA (USER32.@)
727 LRESULT WINAPI
DefWindowProcA( HWND hwnd
, UINT msg
, WPARAM wParam
,
730 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
733 if (!wndPtr
) return 0;
734 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
740 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
741 if (cs
->lpszName
) DEFWND_SetTextA( wndPtr
, cs
->lpszName
);
747 result
= NC_HandleNCCalcSize( wndPtr
, (RECT
*)lParam
);
750 case WM_WINDOWPOSCHANGING
:
751 result
= WINPOS_HandleWindowPosChanging( wndPtr
,
752 (WINDOWPOS
*)lParam
);
755 case WM_WINDOWPOSCHANGED
:
757 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
758 DEFWND_HandleWindowPosChanged( wndPtr
, winPos
->flags
);
763 if (wParam
&& wndPtr
->text
)
765 if (!WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, -1,
766 (LPSTR
)lParam
, wParam
, NULL
, NULL
))
767 ((LPSTR
)lParam
)[wParam
-1] = 0;
768 result
= (LRESULT
)strlen( (LPSTR
)lParam
);
773 DEFWND_SetTextA( wndPtr
, (LPCSTR
)lParam
);
774 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
775 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
776 result
= 1; /* success. FIXME: check text length */
779 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
782 CHAR chChar1
= (CHAR
)( (wParam
>>8) & 0xff );
783 CHAR chChar2
= (CHAR
)( wParam
& 0xff );
785 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar1
, lParam
);
786 if ( IsDBCSLeadByte( chChar1
) )
787 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar2
, lParam
);
791 result
= SendMessageA( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
794 result
= SendMessageA( hwnd
, WM_KEYUP
, wParam
, lParam
);
797 case WM_IME_STARTCOMPOSITION
:
798 case WM_IME_COMPOSITION
:
799 case WM_IME_ENDCOMPOSITION
:
804 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
806 result
= SendMessageA( hwndIME
, msg
, wParam
, lParam
);
809 case WM_IME_SETCONTEXT
:
813 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
815 result
= DEFWND_ImmIsUIMessageA( hwndIME
, msg
, wParam
, lParam
);
820 result
= DEFWND_DefWinProc( wndPtr
, msg
, wParam
, lParam
);
824 WIN_ReleaseWndPtr(wndPtr
);
825 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);
830 /***********************************************************************
831 * DefWindowProcW (USER32.@) Calls default window message handler
833 * Calls default window procedure for messages not processed
837 * Return value is dependent upon the message.
839 LRESULT WINAPI
DefWindowProcW(
840 HWND hwnd
, /* [in] window procedure recieving message */
841 UINT msg
, /* [in] message identifier */
842 WPARAM wParam
, /* [in] first message parameter */
843 LPARAM lParam
) /* [in] second message parameter */
845 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
848 if (!wndPtr
) return 0;
849 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
855 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
856 if (cs
->lpszName
) DEFWND_SetTextW( wndPtr
, cs
->lpszName
);
862 if (wParam
&& wndPtr
->text
)
864 lstrcpynW( (LPWSTR
)lParam
, wndPtr
->text
, wParam
);
865 result
= strlenW( (LPWSTR
)lParam
);
870 DEFWND_SetTextW( wndPtr
, (LPCWSTR
)lParam
);
871 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
872 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
873 result
= 1; /* success. FIXME: check text length */
876 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
878 SendMessageW( hwnd
, WM_CHAR
, wParam
, lParam
);
880 case WM_IME_SETCONTEXT
:
884 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
886 result
= DEFWND_ImmIsUIMessageW( hwndIME
, msg
, wParam
, lParam
);
891 result
= DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
894 WIN_ReleaseWndPtr(wndPtr
);
895 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);