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"
24 DEFAULT_DEBUG_CHANNEL(win
);
26 /* bits in the dwKeyData */
27 #define KEYDATA_ALT 0x2000
28 #define KEYDATA_PREVSTATE 0x4000
30 static short iF10Key
= 0;
31 static short iMenuSysKey
= 0;
33 /***********************************************************************
34 * DEFWND_HandleWindowPosChanged
36 * Handle the WM_WINDOWPOSCHANGED message.
38 static void DEFWND_HandleWindowPosChanged( WND
*wndPtr
, UINT flags
)
40 WPARAM wp
= SIZE_RESTORED
;
42 if (!(flags
& SWP_NOCLIENTMOVE
))
43 SendMessageW( wndPtr
->hwndSelf
, WM_MOVE
, 0,
44 MAKELONG(wndPtr
->rectClient
.left
, wndPtr
->rectClient
.top
));
45 if (!(flags
& SWP_NOCLIENTSIZE
))
47 if (wndPtr
->dwStyle
& WS_MAXIMIZE
) wp
= SIZE_MAXIMIZED
;
48 else if (wndPtr
->dwStyle
& WS_MINIMIZE
) wp
= SIZE_MINIMIZED
;
50 SendMessageW( wndPtr
->hwndSelf
, WM_SIZE
, wp
,
51 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
52 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
57 /***********************************************************************
60 * Set the window text.
62 void DEFWND_SetTextA( WND
*wndPtr
, LPCSTR text
)
67 count
= MultiByteToWideChar( CP_ACP
, 0, text
, -1, NULL
, 0 );
69 if (wndPtr
->text
) HeapFree(GetProcessHeap(), 0, wndPtr
->text
);
70 if ((wndPtr
->text
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(WCHAR
))))
71 MultiByteToWideChar( CP_ACP
, 0, text
, -1, wndPtr
->text
, count
);
73 ERR("Not enough memory for window text");
75 wndPtr
->pDriver
->pSetText(wndPtr
, wndPtr
->text
);
78 /***********************************************************************
81 * Set the window text.
83 void DEFWND_SetTextW( WND
*wndPtr
, LPCWSTR text
)
85 static const WCHAR empty_string
[] = {0};
88 if (!text
) text
= empty_string
;
89 count
= strlenW(text
) + 1;
91 if (wndPtr
->text
) HeapFree(GetProcessHeap(), 0, wndPtr
->text
);
92 if ((wndPtr
->text
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(WCHAR
))))
93 strcpyW( wndPtr
->text
, text
);
95 ERR("Not enough memory for window text");
97 wndPtr
->pDriver
->pSetText(wndPtr
, wndPtr
->text
);
100 /***********************************************************************
101 * DEFWND_ControlColor
103 * Default colors for control painting.
105 HBRUSH
DEFWND_ControlColor( HDC hDC
, UINT ctlType
)
107 if( ctlType
== CTLCOLOR_SCROLLBAR
)
109 HBRUSH hb
= GetSysColorBrush(COLOR_SCROLLBAR
);
110 if (TWEAK_WineLook
== WIN31_LOOK
) {
111 SetTextColor( hDC
, RGB(0, 0, 0) );
112 SetBkColor( hDC
, RGB(255, 255, 255) );
114 COLORREF bk
= GetSysColor(COLOR_3DHILIGHT
);
115 SetTextColor( hDC
, GetSysColor(COLOR_3DFACE
));
116 SetBkColor( hDC
, bk
);
118 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
119 * we better use 0x55aa bitmap brush to make scrollbar's background
120 * look different from the window background.
122 if (bk
== GetSysColor(COLOR_WINDOW
)) {
123 return CACHE_GetPattern55AABrush();
126 UnrealizeObject( hb
);
130 SetTextColor( hDC
, GetSysColor(COLOR_WINDOWTEXT
));
132 if (TWEAK_WineLook
> WIN31_LOOK
) {
133 if ((ctlType
== CTLCOLOR_EDIT
) || (ctlType
== CTLCOLOR_LISTBOX
))
134 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
136 SetBkColor( hDC
, GetSysColor(COLOR_3DFACE
) );
137 return GetSysColorBrush(COLOR_3DFACE
);
141 SetBkColor( hDC
, GetSysColor(COLOR_WINDOW
) );
142 return GetSysColorBrush(COLOR_WINDOW
);
146 /***********************************************************************
149 static void DEFWND_SetRedraw( WND
* wndPtr
, WPARAM wParam
)
151 BOOL bVisible
= wndPtr
->dwStyle
& WS_VISIBLE
;
153 TRACE("%04x %i\n", wndPtr
->hwndSelf
, (wParam
!=0) );
159 wndPtr
->dwStyle
|= WS_VISIBLE
;
160 DCE_InvalidateDCE( wndPtr
, &wndPtr
->rectWindow
);
165 if( wndPtr
->dwStyle
& WS_MINIMIZE
) wParam
= RDW_VALIDATE
;
166 else wParam
= RDW_ALLCHILDREN
| RDW_VALIDATE
;
168 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0, wParam
, 0 );
169 DCE_InvalidateDCE( wndPtr
, &wndPtr
->rectWindow
);
170 wndPtr
->dwStyle
&= ~WS_VISIBLE
;
174 /***********************************************************************
177 * This method handles the default behavior for the WM_PRINT message.
179 static void DEFWND_Print(
187 if ( (uFlags
& PRF_CHECKVISIBLE
) &&
188 !IsWindowVisible(wndPtr
->hwndSelf
) )
192 * Unimplemented flags.
194 if ( (uFlags
& PRF_CHILDREN
) ||
195 (uFlags
& PRF_OWNED
) ||
196 (uFlags
& PRF_NONCLIENT
) )
198 WARN("WM_PRINT message with unsupported flags\n");
204 if ( uFlags
& PRF_ERASEBKGND
)
205 SendMessageW(wndPtr
->hwndSelf
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
210 if ( uFlags
& PRF_CLIENT
)
211 SendMessageW(wndPtr
->hwndSelf
, WM_PRINTCLIENT
, (WPARAM
)hdc
, PRF_CLIENT
);
216 * helpers for calling IMM32
218 * WM_IME_* messages are generated only by IMM32,
219 * so I assume imm32 is already LoadLibrary-ed.
221 static HWND
DEFWND_ImmGetDefaultIMEWnd( HWND hwnd
)
223 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
224 HWND
WINAPI (*pFunc
)(HWND
);
229 ERR( "cannot get IMM32 handle\n" );
233 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmGetDefaultIMEWnd");
235 hwndRet
= (*pFunc
)( hwnd
);
240 static BOOL
DEFWND_ImmIsUIMessageA( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
242 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
243 BOOL
WINAPI (*pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
248 ERR( "cannot get IMM32 handle\n" );
252 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageA");
254 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
259 static BOOL
DEFWND_ImmIsUIMessageW( HWND hwndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
261 HINSTANCE hInstIMM
= GetModuleHandleA( "imm32" );
262 BOOL
WINAPI (*pFunc
)(HWND
,UINT
,WPARAM
,LPARAM
);
267 ERR( "cannot get IMM32 handle\n" );
271 pFunc
= (void*)GetProcAddress(hInstIMM
,"ImmIsUIMessageW");
273 fRet
= (*pFunc
)( hwndIME
, msg
, wParam
, lParam
);
280 /***********************************************************************
283 * Default window procedure for messages that are the same in Win16 and Win32.
285 static LRESULT
DEFWND_DefWinProc( WND
*wndPtr
, UINT msg
, WPARAM wParam
,
286 LPARAM lParam
, BOOL unicode
)
288 LRESULT (WINAPI
*pSendMessage
)(HWND
, UINT
, WPARAM
, LPARAM
);
289 BOOL (WINAPI
*pPostMessage
)(HWND
, UINT
, WPARAM
, LPARAM
);
291 pSendMessage
= unicode
? SendMessageW
: SendMessageA
;
292 pPostMessage
= unicode
? PostMessageW
: PostMessageA
;
297 return NC_HandleNCPaint( wndPtr
->hwndSelf
, (HRGN
)wParam
);
302 pt
.x
= SLOWORD(lParam
);
303 pt
.y
= SHIWORD(lParam
);
304 return NC_HandleNCHitTest( wndPtr
->hwndSelf
, pt
);
307 case WM_NCLBUTTONDOWN
:
308 return NC_HandleNCLButtonDown( wndPtr
, wParam
, lParam
);
310 case WM_LBUTTONDBLCLK
:
311 case WM_NCLBUTTONDBLCLK
:
312 return NC_HandleNCLButtonDblClk( wndPtr
, wParam
, lParam
);
314 case WM_NCRBUTTONDOWN
:
315 /* in Windows, capture is taken when right-clicking on the caption bar */
316 if (wParam
==HTCAPTION
)
318 SetCapture(wndPtr
->hwndSelf
);
323 if (wndPtr
->hwndSelf
== GetCapture())
325 /* release capture if we took it on WM_NCRBUTTONDOWN */
328 if ((wndPtr
->flags
& WIN_ISWIN32
) || (TWEAK_WineLook
> WIN31_LOOK
))
331 pt
.x
= SLOWORD(lParam
);
332 pt
.y
= SHIWORD(lParam
);
333 ClientToScreen(wndPtr
->hwndSelf
, &pt
);
334 lParam
= MAKELPARAM(pt
.x
, pt
.y
);
335 pSendMessage( wndPtr
->hwndSelf
, WM_CONTEXTMENU
, wndPtr
->hwndSelf
, lParam
);
341 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
342 * in Windows), but what _should_ we do? According to MSDN :
343 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
344 * message to the window". When is it appropriate?
349 if( wndPtr
->dwStyle
& WS_CHILD
)
350 pSendMessage( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
351 else if (wndPtr
->hSysMenu
)
355 pt
.x
= SLOWORD(lParam
);
356 pt
.y
= SHIWORD(lParam
);
359 * WM_CONTEXTMENU coordinates are relative to screen, but
360 * NC_HandleNCHitTest expects coordinates relative to the parent's
361 * client area (to compare with the rectangle returned by
365 ScreenToClient(wndPtr
->parent
->hwndSelf
, &pt
);
367 hitcode
= NC_HandleNCHitTest(wndPtr
->hwndSelf
, pt
);
369 /* Track system popup if click was in the caption area. */
370 if (hitcode
==HTCAPTION
|| hitcode
==HTSYSMENU
)
371 TrackPopupMenu(GetSystemMenu(wndPtr
->hwndSelf
, FALSE
),
372 TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
,
373 pt
.x
, pt
.y
, 0, wndPtr
->hwndSelf
, NULL
);
378 return NC_HandleNCActivate( wndPtr
, wParam
);
381 if (wndPtr
->text
) HeapFree( GetProcessHeap(), 0, wndPtr
->text
);
383 if (wndPtr
->pVScroll
) HeapFree( GetProcessHeap(), 0, wndPtr
->pVScroll
);
384 if (wndPtr
->pHScroll
) HeapFree( GetProcessHeap(), 0, wndPtr
->pHScroll
);
385 wndPtr
->pVScroll
= wndPtr
->pHScroll
= NULL
;
389 DEFWND_Print(wndPtr
, (HDC
)wParam
, lParam
);
396 HDC hdc
= BeginPaint( wndPtr
->hwndSelf
, &ps
);
400 if( (wndPtr
->dwStyle
& WS_MINIMIZE
) && ((hIcon
= GetClassLongW( wndPtr
->hwndSelf
, GCL_HICON
))) )
402 int x
= (wndPtr
->rectWindow
.right
- wndPtr
->rectWindow
.left
-
403 GetSystemMetrics(SM_CXICON
))/2;
404 int y
= (wndPtr
->rectWindow
.bottom
- wndPtr
->rectWindow
.top
-
405 GetSystemMetrics(SM_CYICON
))/2;
406 TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
407 ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
408 DrawIcon( hdc
, x
, y
, hIcon
);
410 EndPaint( wndPtr
->hwndSelf
, &ps
);
416 if (wndPtr
->hrgnUpdate
)
418 RedrawWindow ( wndPtr
->hwndSelf
, 0, wndPtr
->hrgnUpdate
,
419 RDW_ERASENOW
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
424 DEFWND_SetRedraw( wndPtr
, wParam
);
428 DestroyWindow( wndPtr
->hwndSelf
);
431 case WM_MOUSEACTIVATE
:
432 if (wndPtr
->dwStyle
& WS_CHILD
)
434 LONG ret
= pSendMessage( wndPtr
->parent
->hwndSelf
,
435 WM_MOUSEACTIVATE
, wParam
, lParam
);
439 /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
440 return (LOWORD(lParam
) >= HTCLIENT
) ? MA_ACTIVATE
: MA_NOACTIVATE
;
443 /* The default action in Windows is to set the keyboard focus to
444 * the window, if it's being activated and not minimized */
445 if (LOWORD(wParam
) != WA_INACTIVE
) {
446 if (!(wndPtr
->dwStyle
& WS_MINIMIZE
))
447 SetFocus(wndPtr
->hwndSelf
);
452 if (wndPtr
->dwStyle
& WS_CHILD
)
454 return pSendMessage( wndPtr
->parent
->hwndSelf
,
455 WM_MOUSEWHEEL
, wParam
, lParam
);
460 case WM_ICONERASEBKGND
:
463 HBRUSH hbr
= GetClassLongW( wndPtr
->hwndSelf
, GCL_HBRBACKGROUND
);
466 /* Since WM_ERASEBKGND may receive either a window dc or a */
467 /* client dc, the area to be erased has to be retrieved from */
468 /* the device context. */
469 GetClipBox( (HDC
)wParam
, &rect
);
471 /* Always call the Win32 variant of FillRect even on Win16,
472 * since despite the fact that Win16, as well as Win32,
473 * supports special background brushes for a window class,
474 * the Win16 variant of FillRect does not.
476 FillRect( (HDC
) wParam
, &rect
, hbr
);
483 case WM_CTLCOLORMSGBOX
:
484 case WM_CTLCOLOREDIT
:
485 case WM_CTLCOLORLISTBOX
:
488 case WM_CTLCOLORSTATIC
:
489 case WM_CTLCOLORSCROLLBAR
:
490 return (LRESULT
)DEFWND_ControlColor( (HDC
)wParam
, msg
- WM_CTLCOLORMSGBOX
);
493 return (LRESULT
)DEFWND_ControlColor( (HDC
)wParam
, HIWORD(lParam
) );
496 if (wndPtr
->dwStyle
& WS_CHILD
)
498 /* with the exception of the border around a resizable wnd,
499 * give the parent first chance to set the cursor */
500 if ((LOWORD(lParam
) < HTSIZEFIRST
) || (LOWORD(lParam
) > HTSIZELAST
))
502 if (pSendMessage(wndPtr
->parent
->hwndSelf
, WM_SETCURSOR
, wParam
, lParam
))
506 return NC_HandleSetCursor( wndPtr
->hwndSelf
, wParam
, lParam
);
511 pt
.x
= SLOWORD(lParam
);
512 pt
.y
= SHIWORD(lParam
);
513 return NC_HandleSysCommand( wndPtr
->hwndSelf
, wParam
, pt
);
517 if(wParam
== VK_F10
) iF10Key
= VK_F10
;
521 if( HIWORD(lParam
) & KEYDATA_ALT
)
523 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
524 if( wParam
== VK_MENU
&& !iMenuSysKey
)
531 if( wParam
== VK_F4
) /* try to close the window */
533 HWND hWnd
= WIN_GetTopParent( wndPtr
->hwndSelf
);
534 wndPtr
= WIN_FindWndPtr( hWnd
);
535 if( wndPtr
&& !(wndPtr
->clsStyle
& CS_NOCLOSE
) )
536 pPostMessage( hWnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0 );
537 WIN_ReleaseWndPtr(wndPtr
);
540 else if( wParam
== VK_F10
)
543 if( wParam
== VK_ESCAPE
&& (GetKeyState(VK_SHIFT
) & 0x8000))
544 pSendMessage( wndPtr
->hwndSelf
, WM_SYSCOMMAND
, SC_KEYMENU
, VK_SPACE
);
549 /* Press and release F10 or ALT */
550 if (((wParam
== VK_MENU
) && iMenuSysKey
) ||
551 ((wParam
== VK_F10
) && iF10Key
))
552 pSendMessage( WIN_GetTopParent(wndPtr
->hwndSelf
),
553 WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
554 iMenuSysKey
= iF10Key
= 0;
559 if (wParam
== VK_RETURN
&& (wndPtr
->dwStyle
& WS_MINIMIZE
))
561 pPostMessage( wndPtr
->hwndSelf
, WM_SYSCOMMAND
, SC_RESTORE
, 0L );
564 if ((HIWORD(lParam
) & KEYDATA_ALT
) && wParam
)
566 if (wParam
== VK_TAB
|| wParam
== VK_ESCAPE
) break;
567 if (wParam
== VK_SPACE
&& (wndPtr
->dwStyle
& WS_CHILD
))
568 pSendMessage( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
570 pSendMessage( wndPtr
->hwndSelf
, WM_SYSCOMMAND
, SC_KEYMENU
, wParam
);
572 else /* check for Ctrl-Esc */
573 if (wParam
!= VK_ESCAPE
) MessageBeep(0);
577 if (!lParam
) return 0; /* sent from ShowWindow */
578 if (!(wndPtr
->dwStyle
& WS_POPUP
) || !wndPtr
->owner
) return 0;
579 if ((wndPtr
->dwStyle
& WS_VISIBLE
) && wParam
) return 0;
580 else if (!(wndPtr
->dwStyle
& WS_VISIBLE
) && !wParam
) return 0;
581 ShowWindow( wndPtr
->hwndSelf
, wParam
? SW_SHOWNOACTIVATE
: SW_HIDE
);
585 if (wndPtr
->parent
== WIN_GetDesktop()) EndMenu();
586 if (GetCapture() == wndPtr
->hwndSelf
) ReleaseCapture();
587 WIN_ReleaseDesktop();
597 case WM_QUERYDROPOBJECT
:
598 if (wndPtr
->dwExStyle
& WS_EX_ACCEPTFILES
) return 1;
601 case WM_QUERYDRAGICON
:
605 HICON hIcon
= GetClassLongW( wndPtr
->hwndSelf
, GCL_HICON
);
606 if (hIcon
) return hIcon
;
607 for(len
=1; len
<64; len
++)
608 if((hIcon
= LoadIconW(wndPtr
->hInstance
, MAKEINTRESOURCEW(len
))))
609 return (LRESULT
)hIcon
;
610 return (LRESULT
)LoadIconW(0, IDI_APPLICATIONW
);
614 case WM_ISACTIVEICON
:
615 return ((wndPtr
->flags
& WIN_NCACTIVATED
) != 0);
617 case WM_NOTIFYFORMAT
:
618 if (IsWindowUnicode(wndPtr
->hwndSelf
)) return NFR_UNICODE
;
619 else return NFR_ANSI
;
622 case WM_QUERYENDSESSION
:
627 int index
= (wParam
!= ICON_SMALL
) ? GCL_HICON
: GCL_HICONSM
;
628 HICON hOldIcon
= GetClassLongW(wndPtr
->hwndSelf
, index
);
629 SetClassLongW(wndPtr
->hwndSelf
, index
, lParam
);
631 SetWindowPos(wndPtr
->hwndSelf
, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
632 | SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
635 if( wndPtr
->flags
& WIN_NATIVE
)
636 wndPtr
->pDriver
->pSetHostAttr(wndPtr
, HAK_ICONS
, 0);
643 int index
= (wParam
!= ICON_SMALL
) ? GCL_HICON
: GCL_HICONSM
;
644 return GetClassLongW(wndPtr
->hwndSelf
, index
);
648 pSendMessage( wndPtr
->parent
->hwndSelf
, msg
, wParam
, lParam
);
657 /***********************************************************************
658 * DefWindowProc (USER.107)
660 LRESULT WINAPI
DefWindowProc16( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
,
663 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
666 if (!wndPtr
) return 0;
667 SPY_EnterMessage( SPY_DEFWNDPROC16
, hwnd
, msg
, wParam
, lParam
);
673 CREATESTRUCT16
*cs
= MapSL(lParam
);
674 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
675 * may have child window IDs instead of window name */
676 if (HIWORD(cs
->lpszName
))
677 DEFWND_SetTextA( wndPtr
, MapSL(cs
->lpszName
) );
685 CONV_RECT16TO32( MapSL(lParam
), &rect32
);
686 result
= NC_HandleNCCalcSize( wndPtr
, &rect32
);
687 CONV_RECT32TO16( &rect32
, MapSL(lParam
) );
691 case WM_WINDOWPOSCHANGING
:
692 result
= WINPOS_HandleWindowPosChanging16( wndPtr
, MapSL(lParam
) );
695 case WM_WINDOWPOSCHANGED
:
697 WINDOWPOS16
* winPos
= MapSL(lParam
);
698 DEFWND_HandleWindowPosChanged( wndPtr
, winPos
->flags
);
702 case WM_GETTEXTLENGTH
:
704 result
= WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, strlenW(wndPtr
->text
),
705 NULL
, 0, NULL
, NULL
);
709 if (wParam
&& wndPtr
->text
)
711 LPSTR dest
= MapSL(lParam
);
712 if (!WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, -1, dest
, wParam
, NULL
, NULL
))
714 result
= strlen(dest
);
719 DEFWND_SetTextA( wndPtr
, MapSL(lParam
) );
720 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
721 NC_HandleNCPaint( hwnd
, (HRGN
)1 );
722 result
= 1; /* success. FIXME: check text length */
726 result
= DEFWND_DefWinProc( wndPtr
, msg
, wParam
, lParam
, FALSE
);
730 WIN_ReleaseWndPtr(wndPtr
);
731 SPY_ExitMessage( SPY_RESULT_DEFWND16
, hwnd
, msg
, result
, wParam
, lParam
);
736 /***********************************************************************
737 * DefWindowProcA (USER32.@)
740 LRESULT WINAPI
DefWindowProcA( HWND hwnd
, UINT msg
, WPARAM wParam
,
743 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
746 if (!wndPtr
) return 0;
747 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
753 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
754 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
755 * may have child window IDs instead of window name */
756 if (HIWORD(cs
->lpszName
))
757 DEFWND_SetTextA( wndPtr
, cs
->lpszName
);
763 result
= NC_HandleNCCalcSize( wndPtr
, (RECT
*)lParam
);
766 case WM_WINDOWPOSCHANGING
:
767 result
= WINPOS_HandleWindowPosChanging( wndPtr
,
768 (WINDOWPOS
*)lParam
);
771 case WM_WINDOWPOSCHANGED
:
773 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
774 DEFWND_HandleWindowPosChanged( wndPtr
, winPos
->flags
);
778 case WM_GETTEXTLENGTH
:
780 result
= WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, strlenW(wndPtr
->text
),
781 NULL
, 0, NULL
, NULL
);
785 if (wParam
&& wndPtr
->text
)
787 if (!WideCharToMultiByte( CP_ACP
, 0, wndPtr
->text
, -1,
788 (LPSTR
)lParam
, wParam
, NULL
, NULL
))
789 ((LPSTR
)lParam
)[wParam
-1] = 0;
790 result
= (LRESULT
)strlen( (LPSTR
)lParam
);
795 DEFWND_SetTextA( wndPtr
, (LPCSTR
)lParam
);
796 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
797 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
798 result
= 1; /* success. FIXME: check text length */
801 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
804 CHAR chChar1
= (CHAR
)( (wParam
>>8) & 0xff );
805 CHAR chChar2
= (CHAR
)( wParam
& 0xff );
807 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar1
, lParam
);
808 if ( IsDBCSLeadByte( chChar1
) )
809 SendMessageA( hwnd
, WM_CHAR
, (WPARAM
)chChar2
, lParam
);
813 result
= SendMessageA( hwnd
, WM_KEYDOWN
, wParam
, lParam
);
816 result
= SendMessageA( hwnd
, WM_KEYUP
, wParam
, lParam
);
819 case WM_IME_STARTCOMPOSITION
:
820 case WM_IME_COMPOSITION
:
821 case WM_IME_ENDCOMPOSITION
:
826 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
828 result
= SendMessageA( hwndIME
, msg
, wParam
, lParam
);
831 case WM_IME_SETCONTEXT
:
835 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
837 result
= DEFWND_ImmIsUIMessageA( hwndIME
, msg
, wParam
, lParam
);
842 result
= DEFWND_DefWinProc( wndPtr
, msg
, wParam
, lParam
, FALSE
);
846 WIN_ReleaseWndPtr(wndPtr
);
847 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);
852 /***********************************************************************
853 * DefWindowProcW (USER32.@) Calls default window message handler
855 * Calls default window procedure for messages not processed
859 * Return value is dependent upon the message.
861 LRESULT WINAPI
DefWindowProcW(
862 HWND hwnd
, /* [in] window procedure recieving message */
863 UINT msg
, /* [in] message identifier */
864 WPARAM wParam
, /* [in] first message parameter */
865 LPARAM lParam
) /* [in] second message parameter */
867 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
870 if (!wndPtr
) return 0;
871 SPY_EnterMessage( SPY_DEFWNDPROC
, hwnd
, msg
, wParam
, lParam
);
877 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
878 /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
879 * may have child window IDs instead of window name */
880 if (HIWORD(cs
->lpszName
))
881 DEFWND_SetTextW( wndPtr
, cs
->lpszName
);
887 result
= NC_HandleNCCalcSize( wndPtr
, (RECT
*)lParam
);
890 case WM_WINDOWPOSCHANGING
:
891 result
= WINPOS_HandleWindowPosChanging( wndPtr
,
892 (WINDOWPOS
*)lParam
);
895 case WM_WINDOWPOSCHANGED
:
897 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
898 DEFWND_HandleWindowPosChanged( wndPtr
, winPos
->flags
);
902 case WM_GETTEXTLENGTH
:
903 if (wndPtr
->text
) result
= (LRESULT
)strlenW(wndPtr
->text
);
907 if (wParam
&& wndPtr
->text
)
909 lstrcpynW( (LPWSTR
)lParam
, wndPtr
->text
, wParam
);
910 result
= strlenW( (LPWSTR
)lParam
);
915 DEFWND_SetTextW( wndPtr
, (LPCWSTR
)lParam
);
916 if( (wndPtr
->dwStyle
& WS_CAPTION
) == WS_CAPTION
)
917 NC_HandleNCPaint( hwnd
, (HRGN
)1 ); /* Repaint caption */
918 result
= 1; /* success. FIXME: check text length */
921 /* for far east users (IMM32) - <hidenori@a2.ctktv.ne.jp> */
923 SendMessageW( hwnd
, WM_CHAR
, wParam
, lParam
);
925 case WM_IME_SETCONTEXT
:
929 hwndIME
= DEFWND_ImmGetDefaultIMEWnd( hwnd
);
931 result
= DEFWND_ImmIsUIMessageW( hwndIME
, msg
, wParam
, lParam
);
936 result
= DEFWND_DefWinProc( wndPtr
, msg
, wParam
, lParam
, TRUE
);
939 WIN_ReleaseWndPtr(wndPtr
);
940 SPY_ExitMessage( SPY_RESULT_DEFWND
, hwnd
, msg
, result
, wParam
, lParam
);