2 * Default window procedure
4 * Copyright 1993, 1996 Alexandre Julliard
13 #include "nonclient.h"
16 #include "debugtools.h"
21 #include "wine/unicode.h"
22 #include "wine/winuser16.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( WND
*wndPtr
, UINT flags
)
41 WPARAM wp
= SIZE_RESTORED
;
43 if (!(flags
& SWP_NOCLIENTMOVE
))
44 SendMessageW( wndPtr
->hwndSelf
, WM_MOVE
, 0,
45 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
));
46 if (!(flags
& SWP_NOCLIENTSIZE
))
48 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wp
= SIZE_MAXIMIZED
;
49 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wp
= SIZE_MINIMIZED
;
51 SendMessageW( wndPtr
->hwndSelf
, WM_SIZE
, wp
,
52 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
53 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
58 /***********************************************************************
61 * Set the window text.
63 void DEFWND_SetTextA( WND
*wndPtr
, LPCSTR text
)
68 count
= MultiByteToWideChar( CP_ACP
, 0, text
, -1, NULL
, 0 );
70 if (wndPtr
->text
) HeapFree(SystemHeap
, 0, wndPtr
->text
);
71 if ((wndPtr
->text
= HeapAlloc(SystemHeap
, 0, count
* sizeof(WCHAR
))))
72 MultiByteToWideChar( CP_ACP
, 0, text
, -1, wndPtr
->text
, count
);
74 ERR("Not enough memory for window text");
76 wndPtr
->pDriver
->pSetText(wndPtr
, wndPtr
->text
);
79 /***********************************************************************
82 * Set the window text.
84 void DEFWND_SetTextW( WND
*wndPtr
, LPCWSTR text
)
86 static const WCHAR empty_string
[] = {0};
89 if (!text
) text
= empty_string
;
90 count
= strlenW(text
) + 1;
92 if (wndPtr
->text
) HeapFree(SystemHeap
, 0, wndPtr
->text
);
93 if ((wndPtr
->text
= HeapAlloc(SystemHeap
, 0, count
* sizeof(WCHAR
))))
94 strcpyW( wndPtr
->text
, text
);
96 ERR("Not enough memory for window text");
98 wndPtr
->pDriver
->pSetText(wndPtr
, wndPtr
->text
);
101 /***********************************************************************
102 * DEFWND_ControlColor
104 * Default colors for control painting.
106 HBRUSH
DEFWND_ControlColor( HDC hDC
, UINT ctlType
)
108 if( ctlType
== CTLCOLOR_SCROLLBAR
)
110 HBRUSH hb
= GetSysColorBrush(COLOR_SCROLLBAR
);
111 if (TWEAK_WineLook
== WIN31_LOOK
) {
112 SetTextColor( hDC
, RGB(0, 0, 0) );
113 SetBkColor( hDC
, RGB(255, 255, 255) );
115 COLORREF bk
= GetSysColor(COLOR_3DHILIGHT
);
116 SetTextColor( hDC
, GetSysColor(COLOR_3DFACE
));
117 SetBkColor( hDC
, bk
);
119 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
120 * we better use 0x55aa bitmap brush to make scrollbar's background
121 * look different from the window background.
123 if (bk
== GetSysColor(COLOR_WINDOW
)) {
124 return CACHE_GetPattern55AABrush();
127 UnrealizeObject( hb
);
131 SetTextColor( hDC
, GetSysColor(COLOR_WINDOWTEXT
));
133 if (TWEAK_WineLook
> WIN31_LOOK
) {
134 if ((ctlType
== CTLCOLOR_EDIT
) || (ctlType
== CTLCOLOR_LISTBOX
))
135 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
137 SetBkColor( hDC
, GetSysColor(COLOR_3DFACE
) );
138 return GetSysColorBrush(COLOR_3DFACE
);
142 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
143 return GetSysColorBrush(COLOR_WINDOW
);
147 /***********************************************************************
150 static void DEFWND_SetRedraw( WND
* wndPtr
, WPARAM wParam
)
152 BOOL bVisible
= wndPtr
->dwStyle
& WS_VISIBLE
;
154 TRACE("%04x %i\n", wndPtr
->hwndSelf
, (wParam
!=0) );
160 wndPtr
->dwStyle
|= WS_VISIBLE
;
161 DCE_InvalidateDCE( wndPtr
, &wndPtr
->rectWindow
);
166 if( wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= RDW_VALIDATE
;
167 else wParam
= RDW_ALLCHILDREN
| RDW_VALIDATE
;
169 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, wParam
, 0 );
170 DCE_InvalidateDCE( wndPtr
, &wndPtr
->rectWindow
);
171 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
175 /***********************************************************************
178 * This method handles the default behavior for the WM_PRINT message.
180 static void DEFWND_Print(
188 if ( (uFlags
& PRF_CHECKVISIBLE
) &&
189 !IsWindowVisible(wndPtr
->hwndSelf
) )
193 * Unimplemented flags.
195 if ( (uFlags
& PRF_CHILDREN
) ||
196 (uFlags
& PRF_OWNED
) ||
197 (uFlags
& PRF_NONCLIENT
) )
199 WARN("WM_PRINT message with unsupported flags\n");
205 if ( uFlags
& PRF_ERASEBKGND
)
206 SendMessageW(wndPtr
->hwndSelf
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
211 if ( uFlags
& PRF_CLIENT
)
212 SendMessageW(wndPtr
->hwndSelf
, WM_PRINTCLIENT
, (WPARAM
)hdc
, PRF_CLIENT
);
217 * helpers for calling IMM32
219 * WM_IME_* messages are generated only by IMM32,
220 * so I assume imm32 is already LoadLibrary-ed.
222 static HWND
DEFWND_ImmGetDefaultIMEWnd( HWND hwnd
)
224 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
225 HWND (WINAPI
* pFunc
)(HWND
);
230 ERR( "cannot get IMM32 handle\n" );
234 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmGetDefaultIMEWnd");
236 hwndRet
= (*pFunc
)( hwnd
);
241 static BOOL
DEFWND_ImmIsUIMessageA( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
243 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
244 BOOL (WINAPI
* pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
249 ERR( "cannot get IMM32 handle\n" );
253 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageA");
255 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
260 static BOOL
DEFWND_ImmIsUIMessageW( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
262 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
263 BOOL (WINAPI
* pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
268 ERR( "cannot get IMM32 handle\n" );
272 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageW");
274 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
281 /***********************************************************************
284 * Default window procedure for messages that are the same in Win16 and Win32.
286 static LRESULT
DEFWND_DefWinProc( WND
*wndPtr
, UINT msg
, WPARAM wParam
,
287 LPARAM lParam
, BOOL unicode
)
289 LRESULT (WINAPI
*pSendMessage
)(HWND
, UINT
, WPARAM
, LPARAM
);
290 BOOL (WINAPI
*pPostMessage
)(HWND
, UINT
, WPARAM
, LPARAM
);
292 pSendMessage
= unicode
? SendMessageW
: SendMessageA
;
293 pPostMessage
= unicode
? PostMessageW
: PostMessageA
;
298 return NC_HandleNCPaint( wndPtr
->hwndSelf
, (HRGN
)wParam
);
303 pt
.x
= SLOWORD(lParam
);
304 pt
.y
= SHIWORD(lParam
);
305 return NC_HandleNCHitTest( wndPtr
->hwndSelf
, pt
);
308 case WM_NCLBUTTONDOWN
:
309 return NC_HandleNCLButtonDown( wndPtr
, wParam
, lParam
);
311 case WM_LBUTTONDBLCLK
:
312 case WM_NCLBUTTONDBLCLK
:
313 return NC_HandleNCLButtonDblClk( wndPtr
, wParam
, lParam
);
315 case WM_NCRBUTTONDOWN
:
316 /* in Windows, capture is taken when right-clicking on the caption bar */
317 if (wParam
==HTCAPTION
)
319 SetCapture(wndPtr
->hwndSelf
);
324 if (wndPtr
->hwndSelf
== GetCapture())
326 /* release capture if we took it on WM_NCRBUTTONDOWN */
329 if ((wndPtr
->flags
& WIN_ISWIN32
) || (TWEAK_WineLook
> WIN31_LOOK
))
332 pt
.x
= SLOWORD(lParam
);
333 pt
.y
= SHIWORD(lParam
);
334 ClientToScreen(wndPtr
->hwndSelf
, &pt
);
335 lParam
= MAKELPARAM(pt
.x
, pt
.y
);
336 pSendMessage( wndPtr
->hwndSelf
, WM_CONTEXTMENU
, wndPtr
->hwndSelf
, lParam
);
342 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
343 * in Windows), but what _should_ we do? According to MSDN :
344 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
345 * message to the window". When is it appropriate?
350 if( wndPtr
->dwStyle
& WS_CHILD
)
351 pSendMessage( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
352 else if (wndPtr
->hSysMenu
)
356 pt
.x
= SLOWORD(lParam
);
357 pt
.y
= SHIWORD(lParam
);
360 * WM_CONTEXTMENU coordinates are relative to screen, but
361 * NC_HandleNCHitTest expects coordinates relative to the parent's
362 * client area (to compare with the rectangle returned by
366 ScreenToClient(wndPtr
->parent
->hwndSelf
, &pt
);
368 hitcode
= NC_HandleNCHitTest(wndPtr
->hwndSelf
, pt
);
370 /* Track system popup if click was in the caption area. */
371 if (hitcode
==HTCAPTION
|| hitcode
==HTSYSMENU
)
372 TrackPopupMenu(GetSystemMenu(wndPtr
->hwndSelf
, FALSE
),
373 TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
,
374 pt
.x
, pt
.y
, 0, wndPtr
->hwndSelf
, NULL
);
379 return NC_HandleNCActivate( wndPtr
, wParam
);
382 if (wndPtr
->text
) HeapFree( SystemHeap
, 0, wndPtr
->text
);
384 if (wndPtr
->pVScroll
) HeapFree( SystemHeap
, 0, wndPtr
->pVScroll
);
385 if (wndPtr
->pHScroll
) HeapFree( SystemHeap
, 0, wndPtr
->pHScroll
);
386 wndPtr
->pVScroll
= wndPtr
->pHScroll
= NULL
;
390 DEFWND_Print(wndPtr
, (HDC
)wParam
, lParam
);
397 HDC hdc
= BeginPaint( wndPtr
->hwndSelf
, &ps
);
401 if( (wndPtr
->dwStyle
& WS_MINIMIZE
) && ((hIcon
= GetClassLongW( wndPtr
->hwndSelf
, GCL_HICON
))) )
403 int x
= (wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
-
404 GetSystemMetrics(SM_CXICON
))/2;
405 int y
= (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
-
406 GetSystemMetrics(SM_CYICON
))/2;
407 TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
408 ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
409 DrawIcon( hdc
, x
, y
, hIcon
);
411 EndPaint( wndPtr
->hwndSelf
, &ps
);
417 if (wndPtr
->hrgnUpdate
)
419 RedrawWindow ( wndPtr
->hwndSelf
, 0, wndPtr
->hrgnUpdate
,
420 RDW_ERASENOW
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
425 DEFWND_SetRedraw( wndPtr
, wParam
);
429 DestroyWindow( wndPtr
->hwndSelf
);
432 case WM_MOUSEACTIVATE
:
433 if (wndPtr
->dwStyle
& WS_CHILD
)
435 LONG ret
= pSendMessage( wndPtr
->parent
->hwndSelf
,
436 WM_MOUSEACTIVATE
, wParam
, lParam
);
440 /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
441 return (LOWORD(lParam
) >= HTCLIENT
) ? MA_ACTIVATE
: MA_NOACTIVATE
;
444 /* The default action in Windows is to set the keyboard focus to
445 * the window, if it's being activated and not minimized */
446 if (LOWORD(wParam
) != WA_INACTIVE
) {
447 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
448 SetFocus(wndPtr
->hwndSelf
);
453 if (wndPtr
->dwStyle
& WS_CHILD
)
455 return pSendMessage( wndPtr
->parent
->hwndSelf
,
456 WM_MOUSEWHEEL
, wParam
, lParam
);
461 case WM_ICONERASEBKGND
:
464 HBRUSH hbr
= GetClassLongW( wndPtr
->hwndSelf
, GCL_HBRBACKGROUND
);
467 /* Since WM_ERASEBKGND may receive either a window dc or a */
468 /* client dc, the area to be erased has to be retrieved from */
469 /* the device context. */
470 GetClipBox( (HDC
)wParam
, &rect
);
472 /* Always call the Win32 variant of FillRect even on Win16,
473 * since despite the fact that Win16, as well as Win32,
474 * supports special background brushes for a window class,
475 * the Win16 variant of FillRect does not.
477 FillRect( (HDC
) wParam
, &rect
, hbr
);
484 case WM_CTLCOLORMSGBOX
:
485 case WM_CTLCOLOREDIT
:
486 case WM_CTLCOLORLISTBOX
:
489 case WM_CTLCOLORSTATIC
:
490 case WM_CTLCOLORSCROLLBAR
:
491 return (LRESULT
)DEFWND_ControlColor( (HDC
)wParam
, msg
- WM_CTLCOLORMSGBOX
);
494 return (LRESULT
)DEFWND_ControlColor( (HDC
)wParam
, HIWORD(lParam
) );
496 case WM_GETTEXTLENGTH
:
497 if (wndPtr
->text
) return (LRESULT
)strlenW(wndPtr
->text
);
501 if (wndPtr
->dwStyle
& WS_CHILD
)
502 if (pSendMessage(wndPtr
->parent
->hwndSelf
, WM_SETCURSOR
,
505 return NC_HandleSetCursor( wndPtr
->hwndSelf
, wParam
, lParam
);
510 pt
.x
= SLOWORD(lParam
);
511 pt
.y
= SHIWORD(lParam
);
512 return NC_HandleSysCommand( wndPtr
->hwndSelf
, wParam
, pt
);
516 if(wParam
== VK_F10
) iF10Key
= VK_F10
;
520 if( HIWORD(lParam
) & KEYDATA_ALT
)
522 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
523 if( wParam
== VK_MENU
&& !iMenuSysKey
)
530 if( wParam
== VK_F4
) /* try to close the window */
532 HWND hWnd
= WIN_GetTopParent( wndPtr
->hwndSelf
);
533 wndPtr
= WIN_FindWndPtr( hWnd
);
534 if( wndPtr
&& !(wndPtr
->clsStyle
& CS_NOCLOSE
) )
535 pPostMessage( hWnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0 );
536 WIN_ReleaseWndPtr(wndPtr
);
539 else if( wParam
== VK_F10
)
542 if( wParam
== VK_ESCAPE
&& (GetKeyState(VK_SHIFT
) & 0x8000))
543 pSendMessage( wndPtr
->hwndSelf
, WM_SYSCOMMAND
, SC_KEYMENU
, VK_SPACE
);
548 /* Press and release F10 or ALT */
549 if (((wParam
== VK_MENU
) && iMenuSysKey
) ||
550 ((wParam
== VK_F10
) && iF10Key
))
551 pSendMessage( WIN_GetTopParent(wndPtr
->hwndSelf
),
552 WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
553 iMenuSysKey
= iF10Key
= 0;
558 if (wParam
== VK_RETURN
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))
560 pPostMessage( wndPtr
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, 0L );
563 if ((HIWORD(lParam
) & KEYDATA_ALT
) && wParam
)
565 if (wParam
== VK_TAB
|| wParam
== VK_ESCAPE
) break;
566 if (wParam
== VK_SPACE
&& (wndPtr
->dwStyle
& WS_CHILD
))
567 pSendMessage( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
569 pSendMessage( wndPtr
->hwndSelf
, WM_SYSCOMMAND
, SC_KEYMENU
, wParam
);
571 else /* check for Ctrl-Esc */
572 if (wParam
!= VK_ESCAPE
) MessageBeep(0);
576 if (!lParam
) return 0; /* sent from ShowWindow */
577 if (!(wndPtr
->dwStyle
& WS_POPUP
) || !wndPtr
->owner
) return 0;
578 if ((wndPtr
->dwStyle
& WS_VISIBLE
) && wParam
) return 0;
579 else if (!(wndPtr
->dwStyle
& WS_VISIBLE
) && !wParam
) return 0;
580 ShowWindow( wndPtr
->hwndSelf
, wParam
? SW_SHOWNOACTIVATE
: SW_HIDE
);
584 if (wndPtr
->parent
== WIN_GetDesktop()) EndMenu();
585 if (GetCapture() == wndPtr
->hwndSelf
) ReleaseCapture();
586 WIN_ReleaseDesktop();
596 case WM_QUERYDROPOBJECT
:
597 if (wndPtr
->dwExStyle
& WS_EX_ACCEPTFILES
) return 1;
600 case WM_QUERYDRAGICON
:
604 HICON hIcon
= GetClassLongW( wndPtr
->hwndSelf
, GCL_HICON
);
605 if (hIcon
) return hIcon
;
606 for(len
=1; len
<64; len
++)
607 if((hIcon
= LoadIconW(wndPtr
->hInstance
, MAKEINTRESOURCEW(len
))))
608 return (LRESULT
)hIcon
;
609 return (LRESULT
)LoadIconW(0, IDI_APPLICATIONW
);
613 case WM_ISACTIVEICON
:
614 return ((wndPtr
->flags
& WIN_NCACTIVATED
) != 0);
616 case WM_NOTIFYFORMAT
:
617 if (IsWindowUnicode(wndPtr
->hwndSelf
)) return NFR_UNICODE
;
618 else return NFR_ANSI
;
621 case WM_QUERYENDSESSION
:
626 int index
= (wParam
!= ICON_SMALL
) ? GCL_HICON
: GCL_HICONSM
;
627 HICON hOldIcon
= GetClassLongW(wndPtr
->hwndSelf
, index
);
628 SetClassLongW(wndPtr
->hwndSelf
, index
, lParam
);
630 SetWindowPos(wndPtr
->hwndSelf
, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
631 | SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
634 if( wndPtr
->flags
& WIN_NATIVE
)
635 wndPtr
->pDriver
->pSetHostAttr(wndPtr
, HAK_ICONS
, 0);
642 int index
= (wParam
!= ICON_SMALL
) ? GCL_HICON
: GCL_HICONSM
;
643 return GetClassLongW(wndPtr
->hwndSelf
, index
);
647 pSendMessage( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
656 /***********************************************************************
657 * DefWindowProc (USER.107)
659 LRESULT WINAPI
DefWindowProc16( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
,
662 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
665 if (!wndPtr
) return 0;
666 SPY_EnterMessage( SPY_DEFWNDPROC16
, hwnd
, msg
, wParam
, lParam
);
672 CREATESTRUCT16
*cs
= MapSL(lParam
);
673 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
674 * may have child window IDs instead of window name */
675 if (HIWORD(cs
->lpszName
))
676 DEFWND_SetTextA( wndPtr
, MapSL(cs
->lpszName
) );
684 CONV_RECT16TO32( MapSL(lParam
), &rect32
);
685 result
= NC_HandleNCCalcSize( wndPtr
, &rect32
);
686 CONV_RECT32TO16( &rect32
, MapSL(lParam
) );
690 case WM_WINDOWPOSCHANGING
:
691 result
= WINPOS_HandleWindowPosChanging16( wndPtr
, MapSL(lParam
) );
694 case WM_WINDOWPOSCHANGED
:
696 WINDOWPOS16
* winPos
= MapSL(lParam
);
697 DEFWND_HandleWindowPosChanged( wndPtr
, winPos
->flags
);
702 if (wParam
&& wndPtr
->text
)
704 LPSTR dest
= MapSL(lParam
);
705 if (!WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, -1, dest
, wParam
, NULL
, NULL
))
707 result
= strlen(dest
);
712 DEFWND_SetTextA( wndPtr
, MapSL(lParam
) );
713 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
714 NC_HandleNCPaint( hwnd
, (HRGN
)1 );
715 result
= 1; /* success. FIXME: check text length */
719 result
= DEFWND_DefWinProc( wndPtr
, msg
, wParam
, lParam
, FALSE
);
723 WIN_ReleaseWndPtr(wndPtr
);
724 SPY_ExitMessage( SPY_RESULT_DEFWND16
, hwnd
, msg
, result
, wParam
, lParam
);
729 /***********************************************************************
730 * DefWindowProcA (USER32.@)
733 LRESULT WINAPI
DefWindowProcA( HWND hwnd
, UINT msg
, WPARAM wParam
,
736 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
739 if (!wndPtr
) return 0;
740 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
746 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
747 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
748 * may have child window IDs instead of window name */
749 if (HIWORD(cs
->lpszName
))
750 DEFWND_SetTextA( wndPtr
, cs
->lpszName
);
756 result
= NC_HandleNCCalcSize( wndPtr
, (RECT
*)lParam
);
759 case WM_WINDOWPOSCHANGING
:
760 result
= WINPOS_HandleWindowPosChanging( wndPtr
,
761 (WINDOWPOS
*)lParam
);
764 case WM_WINDOWPOSCHANGED
:
766 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
767 DEFWND_HandleWindowPosChanged( wndPtr
, winPos
->flags
);
772 if (wParam
&& wndPtr
->text
)
774 if (!WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, -1,
775 (LPSTR
)lParam
, wParam
, NULL
, NULL
))
776 ((LPSTR
)lParam
)[wParam
-1] = 0;
777 result
= (LRESULT
)strlen( (LPSTR
)lParam
);
782 DEFWND_SetTextA( wndPtr
, (LPCSTR
)lParam
);
783 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
784 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
785 result
= 1; /* success. FIXME: check text length */
788 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
791 CHAR chChar1
= (CHAR
)( (wParam
>>8) & 0xff );
792 CHAR chChar2
= (CHAR
)( wParam
& 0xff );
794 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar1
, lParam
);
795 if ( IsDBCSLeadByte( chChar1
) )
796 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar2
, lParam
);
800 result
= SendMessageA( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
803 result
= SendMessageA( hwnd
, WM_KEYUP
, wParam
, lParam
);
806 case WM_IME_STARTCOMPOSITION
:
807 case WM_IME_COMPOSITION
:
808 case WM_IME_ENDCOMPOSITION
:
813 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
815 result
= SendMessageA( hwndIME
, msg
, wParam
, lParam
);
818 case WM_IME_SETCONTEXT
:
822 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
824 result
= DEFWND_ImmIsUIMessageA( hwndIME
, msg
, wParam
, lParam
);
829 result
= DEFWND_DefWinProc( wndPtr
, msg
, wParam
, lParam
, FALSE
);
833 WIN_ReleaseWndPtr(wndPtr
);
834 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);
839 /***********************************************************************
840 * DefWindowProcW (USER32.@) Calls default window message handler
842 * Calls default window procedure for messages not processed
846 * Return value is dependent upon the message.
848 LRESULT WINAPI
DefWindowProcW(
849 HWND hwnd
, /* [in] window procedure recieving message */
850 UINT msg
, /* [in] message identifier */
851 WPARAM wParam
, /* [in] first message parameter */
852 LPARAM lParam
) /* [in] second message parameter */
854 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
857 if (!wndPtr
) return 0;
858 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
864 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
865 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
866 * may have child window IDs instead of window name */
867 if (HIWORD(cs
->lpszName
))
868 DEFWND_SetTextW( wndPtr
, cs
->lpszName
);
874 result
= NC_HandleNCCalcSize( wndPtr
, (RECT
*)lParam
);
877 case WM_WINDOWPOSCHANGING
:
878 result
= WINPOS_HandleWindowPosChanging( wndPtr
,
879 (WINDOWPOS
*)lParam
);
882 case WM_WINDOWPOSCHANGED
:
884 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
885 DEFWND_HandleWindowPosChanged( wndPtr
, winPos
->flags
);
890 if (wParam
&& wndPtr
->text
)
892 lstrcpynW( (LPWSTR
)lParam
, wndPtr
->text
, wParam
);
893 result
= strlenW( (LPWSTR
)lParam
);
898 DEFWND_SetTextW( wndPtr
, (LPCWSTR
)lParam
);
899 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
900 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
901 result
= 1; /* success. FIXME: check text length */
904 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
906 SendMessageW( hwnd
, WM_CHAR
, wParam
, lParam
);
908 case WM_IME_SETCONTEXT
:
912 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
914 result
= DEFWND_ImmIsUIMessageW( hwndIME
, msg
, wParam
, lParam
);
919 result
= DEFWND_DefWinProc( wndPtr
, msg
, wParam
, lParam
, TRUE
);
922 WIN_ReleaseWndPtr(wndPtr
);
923 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);