Use lcall opcodes, so all gas-es understand it...
[wine.git] / windows / defwnd.c
bloba1bc1f9b3f1e34b4d6599e83be55f6d8e058288f
1 /*
2 * Default window procedure
4 * Copyright 1993, 1996 Alexandre Julliard
5 * 1995 Alex Korobka
6 */
8 #include <string.h>
10 #include "class.h"
11 #include "win.h"
12 #include "user.h"
13 #include "heap.h"
14 #include "nonclient.h"
15 #include "winpos.h"
16 #include "dce.h"
17 #include "debugtools.h"
18 #include "spy.h"
19 #include "tweak.h"
20 #include "cache.h"
21 #include "windef.h"
22 #include "wingdi.h"
23 #include "winnls.h"
24 #include "wine/unicode.h"
25 #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 /***********************************************************************
61 * DEFWND_SetTextA
63 * Set the window text.
65 void DEFWND_SetTextA( WND *wndPtr, LPCSTR text )
67 int count;
69 if (!text) 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 );
75 else
76 ERR("Not enough memory for window text");
78 wndPtr->pDriver->pSetText(wndPtr, wndPtr->text);
81 /***********************************************************************
82 * DEFWND_SetTextW
84 * Set the window text.
86 void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text )
88 static const WCHAR empty_string[] = {0};
89 int count;
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 lstrcpyW( wndPtr->text, text );
97 else
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) );
116 } else {
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 );
130 return 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) );
138 else {
139 SetBkColor( hDC, GetSysColor(COLOR_3DFACE) );
140 return GetSysColorBrush(COLOR_3DFACE);
143 else
144 SetBkColor( hDC, GetSysColor(COLOR_WINDOW) );
145 return GetSysColorBrush(COLOR_WINDOW);
149 /***********************************************************************
150 * DEFWND_SetRedraw
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) );
158 if( wParam )
160 if( !bVisible )
162 wndPtr->dwStyle |= WS_VISIBLE;
163 DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
166 else if( bVisible )
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 /***********************************************************************
178 * DEFWND_Print
180 * This method handles the default behavior for the WM_PRINT message.
182 static void DEFWND_Print(
183 WND* wndPtr,
184 HDC hdc,
185 ULONG uFlags)
188 * Visibility flag.
190 if ( (uFlags & PRF_CHECKVISIBLE) &&
191 !IsWindowVisible(wndPtr->hwndSelf) )
192 return;
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");
205 * Background
207 if ( uFlags & PRF_ERASEBKGND)
208 SendMessageA(wndPtr->hwndSelf, WM_ERASEBKGND, (WPARAM)hdc, 0);
211 * Client area
213 if ( uFlags & PRF_CLIENT)
214 SendMessageA(wndPtr->hwndSelf, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
217 /***********************************************************************
218 * DEFWND_DefWinProc
220 * Default window procedure for messages that are the same in Win16 and Win32.
222 static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
223 LPARAM lParam )
225 switch(msg)
227 case WM_NCPAINT:
228 return NC_HandleNCPaint( wndPtr->hwndSelf, (HRGN)wParam );
230 case WM_NCHITTEST:
231 return NC_HandleNCHitTest( wndPtr->hwndSelf, MAKEPOINT16(lParam) );
233 case WM_NCLBUTTONDOWN:
234 return NC_HandleNCLButtonDown( wndPtr, wParam, lParam );
236 case WM_LBUTTONDBLCLK:
237 case WM_NCLBUTTONDBLCLK:
238 return NC_HandleNCLButtonDblClk( wndPtr, wParam, lParam );
240 case WM_RBUTTONUP:
241 case WM_NCRBUTTONUP:
242 if ((wndPtr->flags & WIN_ISWIN32) || (TWEAK_WineLook > WIN31_LOOK))
244 ClientToScreen16(wndPtr->hwndSelf, (LPPOINT16)&lParam);
245 SendMessageA( wndPtr->hwndSelf, WM_CONTEXTMENU,
246 wndPtr->hwndSelf, lParam);
248 break;
250 case WM_CONTEXTMENU:
251 if( wndPtr->dwStyle & WS_CHILD )
252 SendMessageA( wndPtr->parent->hwndSelf, msg, wParam, lParam );
253 else if (wndPtr->hSysMenu)
255 LONG hitcode;
256 POINT16 pt = MAKEPOINT16(lParam);
258 ScreenToClient16(wndPtr->hwndSelf, &pt);
259 hitcode = NC_HandleNCHitTest(wndPtr->hwndSelf, pt);
261 /* Track system popup if click was in the caption area. */
262 if (hitcode==HTCAPTION || hitcode==HTSYSMENU)
263 TrackPopupMenu(GetSystemMenu(wndPtr->hwndSelf, FALSE),
264 TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
265 pt.x, pt.y, 0, wndPtr->hwndSelf, NULL);
267 break;
269 case WM_NCACTIVATE:
270 return NC_HandleNCActivate( wndPtr, wParam );
272 case WM_NCDESTROY:
273 if (wndPtr->text) HeapFree( SystemHeap, 0, wndPtr->text );
274 wndPtr->text = NULL;
275 if (wndPtr->pVScroll) HeapFree( SystemHeap, 0, wndPtr->pVScroll );
276 if (wndPtr->pHScroll) HeapFree( SystemHeap, 0, wndPtr->pHScroll );
277 wndPtr->pVScroll = wndPtr->pHScroll = NULL;
278 return 0;
280 case WM_PRINT:
281 DEFWND_Print(wndPtr, (HDC)wParam, lParam);
282 return 0;
284 case WM_PAINTICON:
285 case WM_PAINT:
287 PAINTSTRUCT16 ps;
288 HDC16 hdc = BeginPaint16( wndPtr->hwndSelf, &ps );
289 if( hdc )
291 if( (wndPtr->dwStyle & WS_MINIMIZE) && wndPtr->class->hIcon )
293 int x = (wndPtr->rectWindow.right - wndPtr->rectWindow.left -
294 GetSystemMetrics(SM_CXICON))/2;
295 int y = (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top -
296 GetSystemMetrics(SM_CYICON))/2;
297 TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
298 ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom );
299 DrawIcon( hdc, x, y, wndPtr->class->hIcon );
301 EndPaint16( wndPtr->hwndSelf, &ps );
303 return 0;
306 case WM_SETREDRAW:
307 DEFWND_SetRedraw( wndPtr, wParam );
308 return 0;
310 case WM_CLOSE:
311 DestroyWindow( wndPtr->hwndSelf );
312 return 0;
314 case WM_MOUSEACTIVATE:
315 if (wndPtr->dwStyle & WS_CHILD)
317 LONG ret = SendMessage16( wndPtr->parent->hwndSelf,
318 WM_MOUSEACTIVATE, wParam, lParam );
319 if (ret) return ret;
322 /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
323 return (LOWORD(lParam) >= HTCLIENT) ? MA_ACTIVATE : MA_NOACTIVATE;
325 case WM_ACTIVATE:
326 /* The default action in Windows is to set the keyboard focus to
327 * the window, if it's being activated and not minimized */
328 if (LOWORD(wParam) != WA_INACTIVE) {
329 if (!(wndPtr->dwStyle & WS_MINIMIZE))
330 SetFocus(wndPtr->hwndSelf);
332 break;
334 case WM_MOUSEWHEEL:
335 if (wndPtr->dwStyle & WS_CHILD)
337 return SendMessageA( wndPtr->parent->hwndSelf,
338 WM_MOUSEWHEEL, wParam, lParam );
340 break;
342 case WM_ERASEBKGND:
343 case WM_ICONERASEBKGND:
345 RECT rect;
347 if (!wndPtr->class->hbrBackground) return 0;
349 /* Since WM_ERASEBKGND may receive either a window dc or a */
350 /* client dc, the area to be erased has to be retrieved from */
351 /* the device context. */
352 GetClipBox( (HDC)wParam, &rect );
354 /* Always call the Win32 variant of FillRect even on Win16,
355 * since despite the fact that Win16, as well as Win32,
356 * supports special background brushes for a window class,
357 * the Win16 variant of FillRect does not.
359 FillRect( (HDC) wParam, &rect, wndPtr->class->hbrBackground);
360 return 1;
363 case WM_GETDLGCODE:
364 return 0;
366 case WM_CTLCOLORMSGBOX:
367 case WM_CTLCOLOREDIT:
368 case WM_CTLCOLORLISTBOX:
369 case WM_CTLCOLORBTN:
370 case WM_CTLCOLORDLG:
371 case WM_CTLCOLORSTATIC:
372 case WM_CTLCOLORSCROLLBAR:
373 return (LRESULT)DEFWND_ControlColor( (HDC)wParam, msg - WM_CTLCOLORMSGBOX );
375 case WM_CTLCOLOR:
376 return (LRESULT)DEFWND_ControlColor( (HDC)wParam, HIWORD(lParam) );
378 case WM_GETTEXTLENGTH:
379 if (wndPtr->text) return (LRESULT)strlenW(wndPtr->text);
380 return 0;
382 case WM_SETCURSOR:
383 if (wndPtr->dwStyle & WS_CHILD)
384 if (SendMessage16(wndPtr->parent->hwndSelf, WM_SETCURSOR,
385 wParam, lParam))
386 return TRUE;
387 return NC_HandleSetCursor( wndPtr->hwndSelf, wParam, lParam );
389 case WM_SYSCOMMAND:
390 return NC_HandleSysCommand( wndPtr->hwndSelf, wParam,
391 MAKEPOINT16(lParam) );
393 case WM_KEYDOWN:
394 if(wParam == VK_F10) iF10Key = VK_F10;
395 break;
397 case WM_SYSKEYDOWN:
398 if( HIWORD(lParam) & KEYDATA_ALT )
400 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
401 if( wParam == VK_MENU && !iMenuSysKey )
402 iMenuSysKey = 1;
403 else
404 iMenuSysKey = 0;
406 iF10Key = 0;
408 if( wParam == VK_F4 ) /* try to close the window */
410 HWND hWnd = WIN_GetTopParent( wndPtr->hwndSelf );
411 wndPtr = WIN_FindWndPtr( hWnd );
412 if( wndPtr && !(wndPtr->class->style & CS_NOCLOSE) )
413 PostMessage16( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
414 WIN_ReleaseWndPtr(wndPtr);
417 else if( wParam == VK_F10 )
418 iF10Key = 1;
419 else
420 if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
421 SendMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND,
422 (WPARAM16)SC_KEYMENU, (LPARAM)VK_SPACE);
423 break;
425 case WM_KEYUP:
426 case WM_SYSKEYUP:
427 /* Press and release F10 or ALT */
428 if (((wParam == VK_MENU) && iMenuSysKey) ||
429 ((wParam == VK_F10) && iF10Key))
430 SendMessage16( WIN_GetTopParent(wndPtr->hwndSelf),
431 WM_SYSCOMMAND, SC_KEYMENU, 0L );
432 iMenuSysKey = iF10Key = 0;
433 break;
435 case WM_SYSCHAR:
436 iMenuSysKey = 0;
437 if (wParam == VK_RETURN && (wndPtr->dwStyle & WS_MINIMIZE))
439 PostMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND,
440 (WPARAM16)SC_RESTORE, 0L );
441 break;
443 if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
445 if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
446 if (wParam == VK_SPACE && (wndPtr->dwStyle & WS_CHILD))
447 SendMessage16( wndPtr->parent->hwndSelf, msg, wParam, lParam );
448 else
449 SendMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND,
450 (WPARAM16)SC_KEYMENU, (LPARAM)(DWORD)wParam );
452 else /* check for Ctrl-Esc */
453 if (wParam != VK_ESCAPE) MessageBeep(0);
454 break;
456 case WM_SHOWWINDOW:
457 if (!lParam) return 0; /* sent from ShowWindow */
458 if (!(wndPtr->dwStyle & WS_POPUP) || !wndPtr->owner) return 0;
459 if ((wndPtr->dwStyle & WS_VISIBLE) && wParam) return 0;
460 else if (!(wndPtr->dwStyle & WS_VISIBLE) && !wParam) return 0;
461 ShowWindow( wndPtr->hwndSelf, wParam ? SW_SHOWNOACTIVATE : SW_HIDE );
462 break;
464 case WM_CANCELMODE:
465 if (wndPtr->parent == WIN_GetDesktop()) EndMenu();
466 if (GetCapture() == wndPtr->hwndSelf) ReleaseCapture();
467 WIN_ReleaseDesktop();
468 break;
470 case WM_VKEYTOITEM:
471 case WM_CHARTOITEM:
472 return -1;
474 case WM_DROPOBJECT:
475 return DRAG_FILE;
477 case WM_QUERYDROPOBJECT:
478 if (wndPtr->dwExStyle & WS_EX_ACCEPTFILES) return 1;
479 break;
481 case WM_QUERYDRAGICON:
483 HICON16 hIcon=0;
484 UINT16 len;
486 if( (hIcon=wndPtr->class->hCursor) ) return (LRESULT)hIcon;
487 for(len=1; len<64; len++)
488 if((hIcon=LoadIcon16(wndPtr->hInstance,MAKEINTRESOURCE16(len))))
489 return (LRESULT)hIcon;
490 return (LRESULT)LoadIcon16(0,IDI_APPLICATION16);
492 break;
494 case WM_ISACTIVEICON:
495 return ((wndPtr->flags & WIN_NCACTIVATED) != 0);
497 case WM_NOTIFYFORMAT:
498 if (IsWindowUnicode(wndPtr->hwndSelf)) return NFR_UNICODE;
499 else return NFR_ANSI;
501 case WM_QUERYOPEN:
502 case WM_QUERYENDSESSION:
503 return 1;
505 case WM_SETICON:
507 int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
508 HICON16 hOldIcon = GetClassLongA(wndPtr->hwndSelf, index);
509 SetClassLongA(wndPtr->hwndSelf, index, lParam);
511 SetWindowPos(wndPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
512 | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE
513 | SWP_NOZORDER);
515 if( wndPtr->flags & WIN_NATIVE )
516 wndPtr->pDriver->pSetHostAttr(wndPtr, HAK_ICONS, 0);
518 return hOldIcon;
521 case WM_GETICON:
523 int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
524 return GetClassLongA(wndPtr->hwndSelf, index);
527 case WM_HELP:
528 SendMessageA( wndPtr->parent->hwndSelf, msg, wParam, lParam );
529 break;
532 return 0;
537 /***********************************************************************
538 * DefWindowProc16 (USER.107)
540 LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
541 LPARAM lParam )
543 WND * wndPtr = WIN_FindWndPtr( hwnd );
544 LRESULT result = 0;
546 if (!wndPtr) return 0;
547 SPY_EnterMessage( SPY_DEFWNDPROC16, hwnd, msg, wParam, lParam );
549 switch(msg)
551 case WM_NCCREATE:
553 CREATESTRUCT16 *cs = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam);
554 if (cs->lpszName)
555 DEFWND_SetTextA( wndPtr, (LPCSTR)PTR_SEG_TO_LIN(cs->lpszName) );
556 result = 1;
558 break;
560 case WM_NCCALCSIZE:
562 RECT rect32;
563 CONV_RECT16TO32( (RECT16 *)PTR_SEG_TO_LIN(lParam), &rect32 );
564 result = NC_HandleNCCalcSize( wndPtr, &rect32 );
565 CONV_RECT32TO16( &rect32, (RECT16 *)PTR_SEG_TO_LIN(lParam) );
567 break;
569 case WM_WINDOWPOSCHANGING:
570 result = WINPOS_HandleWindowPosChanging16( wndPtr,
571 (WINDOWPOS16 *)PTR_SEG_TO_LIN(lParam) );
572 break;
574 case WM_WINDOWPOSCHANGED:
576 WINDOWPOS16 * winPos = (WINDOWPOS16 *)PTR_SEG_TO_LIN(lParam);
577 DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags );
579 break;
581 case WM_GETTEXT:
582 if (wParam && wndPtr->text)
584 lstrcpynWtoA( (LPSTR)PTR_SEG_TO_LIN(lParam), wndPtr->text, wParam );
585 result = (LRESULT)strlen( (LPSTR)PTR_SEG_TO_LIN(lParam) );
587 break;
589 case WM_SETTEXT:
590 DEFWND_SetTextA( wndPtr, (LPCSTR)PTR_SEG_TO_LIN(lParam) );
591 if( wndPtr->dwStyle & WS_CAPTION ) NC_HandleNCPaint( hwnd , (HRGN)1 );
592 break;
594 default:
595 result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam );
596 break;
599 WIN_ReleaseWndPtr(wndPtr);
600 SPY_ExitMessage( SPY_RESULT_DEFWND16, hwnd, msg, result );
601 return result;
605 /***********************************************************************
606 * DefWindowProcA [USER32.126]
609 LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
610 LPARAM lParam )
612 WND * wndPtr = WIN_FindWndPtr( hwnd );
613 LRESULT result = 0;
615 if (!wndPtr) return 0;
616 SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
618 switch(msg)
620 case WM_NCCREATE:
622 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
623 if (cs->lpszName) DEFWND_SetTextA( wndPtr, cs->lpszName );
624 result = 1;
626 break;
628 case WM_NCCALCSIZE:
629 result = NC_HandleNCCalcSize( wndPtr, (RECT *)lParam );
630 break;
632 case WM_WINDOWPOSCHANGING:
633 result = WINPOS_HandleWindowPosChanging( wndPtr,
634 (WINDOWPOS *)lParam );
635 break;
637 case WM_WINDOWPOSCHANGED:
639 WINDOWPOS * winPos = (WINDOWPOS *)lParam;
640 DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags );
642 break;
644 case WM_GETTEXT:
645 if (wParam && wndPtr->text)
647 lstrcpynWtoA( (LPSTR)lParam, wndPtr->text, wParam );
648 result = (LRESULT)strlen( (LPSTR)lParam );
650 break;
652 case WM_SETTEXT:
653 DEFWND_SetTextA( wndPtr, (LPCSTR)lParam );
654 NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
655 break;
657 default:
658 result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam );
659 break;
662 WIN_ReleaseWndPtr(wndPtr);
663 SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result );
664 return result;
668 /***********************************************************************
669 * DefWindowProcW [USER32.127] Calls default window message handler
671 * Calls default window procedure for messages not processed
672 * by application.
674 * RETURNS
675 * Return value is dependent upon the message.
677 LRESULT WINAPI DefWindowProcW(
678 HWND hwnd, /* [in] window procedure recieving message */
679 UINT msg, /* [in] message identifier */
680 WPARAM wParam, /* [in] first message parameter */
681 LPARAM lParam ) /* [in] second message parameter */
683 WND * wndPtr = WIN_FindWndPtr( hwnd );
684 LRESULT result = 0;
686 if (!wndPtr) return 0;
687 switch(msg)
689 case WM_NCCREATE:
691 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
692 if (cs->lpszName) DEFWND_SetTextW( wndPtr, cs->lpszName );
693 result = 1;
695 break;
697 case WM_GETTEXT:
698 if (wParam && wndPtr->text)
700 lstrcpynW( (LPWSTR)lParam, wndPtr->text, wParam );
701 result = strlenW( (LPWSTR)lParam );
703 break;
705 case WM_SETTEXT:
706 DEFWND_SetTextW( wndPtr, (LPCWSTR)lParam );
707 NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
708 break;
710 default:
711 result = DefWindowProcA( hwnd, msg, wParam, lParam );
712 break;
714 WIN_ReleaseWndPtr(wndPtr);
715 return result;