- Implemented 73 CRT functions
[wine/hacks.git] / windows / defwnd.c
blob1e53645a13519b8757ed179c687cabc810f21d7a
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"
26 #include "wine/winestring.h"
28 DEFAULT_DEBUG_CHANNEL(win);
30 /* bits in the dwKeyData */
31 #define KEYDATA_ALT 0x2000
32 #define KEYDATA_PREVSTATE 0x4000
34 static short iF10Key = 0;
35 static short iMenuSysKey = 0;
37 /***********************************************************************
38 * DEFWND_HandleWindowPosChanged
40 * Handle the WM_WINDOWPOSCHANGED message.
42 static void DEFWND_HandleWindowPosChanged( WND *wndPtr, UINT flags )
44 WPARAM16 wp = SIZE_RESTORED;
46 if (!(flags & SWP_NOCLIENTMOVE))
47 SendMessage16( wndPtr->hwndSelf, WM_MOVE, 0,
48 MAKELONG(wndPtr->rectClient.left, wndPtr->rectClient.top));
49 if (!(flags & SWP_NOCLIENTSIZE))
51 if (wndPtr->dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
52 else if (wndPtr->dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
54 SendMessage16( wndPtr->hwndSelf, WM_SIZE, wp,
55 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
56 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
61 /***********************************************************************
62 * DEFWND_SetTextA
64 * Set the window text.
66 void DEFWND_SetTextA( WND *wndPtr, LPCSTR text )
68 int count;
70 if (!text) text = "";
71 count = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
73 if (wndPtr->text) HeapFree(SystemHeap, 0, wndPtr->text);
74 if ((wndPtr->text = HeapAlloc(SystemHeap, 0, count * sizeof(WCHAR))))
75 MultiByteToWideChar( CP_ACP, 0, text, -1, wndPtr->text, count );
76 else
77 ERR("Not enough memory for window text");
79 wndPtr->pDriver->pSetText(wndPtr, wndPtr->text);
82 /***********************************************************************
83 * DEFWND_SetTextW
85 * Set the window text.
87 void DEFWND_SetTextW( WND *wndPtr, LPCWSTR text )
89 static const WCHAR empty_string[] = {0};
90 int count;
92 if (!text) text = empty_string;
93 count = strlenW(text) + 1;
95 if (wndPtr->text) HeapFree(SystemHeap, 0, wndPtr->text);
96 if ((wndPtr->text = HeapAlloc(SystemHeap, 0, count * sizeof(WCHAR))))
97 strcpyW( wndPtr->text, text );
98 else
99 ERR("Not enough memory for window text");
101 wndPtr->pDriver->pSetText(wndPtr, wndPtr->text);
104 /***********************************************************************
105 * DEFWND_ControlColor
107 * Default colors for control painting.
109 HBRUSH DEFWND_ControlColor( HDC hDC, UINT16 ctlType )
111 if( ctlType == CTLCOLOR_SCROLLBAR)
113 HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
114 if (TWEAK_WineLook == WIN31_LOOK) {
115 SetTextColor( hDC, RGB(0, 0, 0) );
116 SetBkColor( hDC, RGB(255, 255, 255) );
117 } else {
118 COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
119 SetTextColor( hDC, GetSysColor(COLOR_3DFACE));
120 SetBkColor( hDC, bk);
122 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
123 * we better use 0x55aa bitmap brush to make scrollbar's background
124 * look different from the window background.
126 if (bk == GetSysColor(COLOR_WINDOW)) {
127 return CACHE_GetPattern55AABrush();
130 UnrealizeObject( hb );
131 return hb;
134 SetTextColor( hDC, GetSysColor(COLOR_WINDOWTEXT));
136 if (TWEAK_WineLook > WIN31_LOOK) {
137 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
138 SetBkColor( hDC, GetSysColor(COLOR_WINDOW) );
139 else {
140 SetBkColor( hDC, GetSysColor(COLOR_3DFACE) );
141 return GetSysColorBrush(COLOR_3DFACE);
144 else
145 SetBkColor( hDC, GetSysColor(COLOR_WINDOW) );
146 return GetSysColorBrush(COLOR_WINDOW);
150 /***********************************************************************
151 * DEFWND_SetRedraw
153 static void DEFWND_SetRedraw( WND* wndPtr, WPARAM wParam )
155 BOOL bVisible = wndPtr->dwStyle & WS_VISIBLE;
157 TRACE("%04x %i\n", wndPtr->hwndSelf, (wParam!=0) );
159 if( wParam )
161 if( !bVisible )
163 wndPtr->dwStyle |= WS_VISIBLE;
164 DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
167 else if( bVisible )
169 if( wndPtr->dwStyle & WS_MINIMIZE ) wParam = RDW_VALIDATE;
170 else wParam = RDW_ALLCHILDREN | RDW_VALIDATE;
172 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, wParam, 0 );
173 DCE_InvalidateDCE( wndPtr, &wndPtr->rectWindow );
174 wndPtr->dwStyle &= ~WS_VISIBLE;
178 /***********************************************************************
179 * DEFWND_Print
181 * This method handles the default behavior for the WM_PRINT message.
183 static void DEFWND_Print(
184 WND* wndPtr,
185 HDC hdc,
186 ULONG uFlags)
189 * Visibility flag.
191 if ( (uFlags & PRF_CHECKVISIBLE) &&
192 !IsWindowVisible(wndPtr->hwndSelf) )
193 return;
196 * Unimplemented flags.
198 if ( (uFlags & PRF_CHILDREN) ||
199 (uFlags & PRF_OWNED) ||
200 (uFlags & PRF_NONCLIENT) )
202 WARN("WM_PRINT message with unsupported flags\n");
206 * Background
208 if ( uFlags & PRF_ERASEBKGND)
209 SendMessageA(wndPtr->hwndSelf, WM_ERASEBKGND, (WPARAM)hdc, 0);
212 * Client area
214 if ( uFlags & PRF_CLIENT)
215 SendMessageA(wndPtr->hwndSelf, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
218 /***********************************************************************
219 * DEFWND_DefWinProc
221 * Default window procedure for messages that are the same in Win16 and Win32.
223 static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam,
224 LPARAM lParam )
226 switch(msg)
228 case WM_NCPAINT:
229 return NC_HandleNCPaint( wndPtr->hwndSelf, (HRGN)wParam );
231 case WM_NCHITTEST:
233 POINT pt;
234 pt.x = SLOWORD(lParam);
235 pt.y = SHIWORD(lParam);
236 return NC_HandleNCHitTest( wndPtr->hwndSelf, pt );
239 case WM_NCLBUTTONDOWN:
240 return NC_HandleNCLButtonDown( wndPtr, wParam, lParam );
242 case WM_LBUTTONDBLCLK:
243 case WM_NCLBUTTONDBLCLK:
244 return NC_HandleNCLButtonDblClk( wndPtr, wParam, lParam );
246 case WM_RBUTTONUP:
247 case WM_NCRBUTTONUP:
248 if ((wndPtr->flags & WIN_ISWIN32) || (TWEAK_WineLook > WIN31_LOOK))
250 ClientToScreen16(wndPtr->hwndSelf, (LPPOINT16)&lParam);
251 SendMessageA( wndPtr->hwndSelf, WM_CONTEXTMENU,
252 wndPtr->hwndSelf, lParam);
254 break;
256 case WM_CONTEXTMENU:
257 if( wndPtr->dwStyle & WS_CHILD )
258 SendMessageA( wndPtr->parent->hwndSelf, msg, wParam, lParam );
259 else if (wndPtr->hSysMenu)
261 LONG hitcode;
262 POINT pt;
263 pt.x = SLOWORD(lParam);
264 pt.y = SHIWORD(lParam);
266 ScreenToClient(wndPtr->hwndSelf, &pt);
267 hitcode = NC_HandleNCHitTest(wndPtr->hwndSelf, pt);
269 /* Track system popup if click was in the caption area. */
270 if (hitcode==HTCAPTION || hitcode==HTSYSMENU)
271 TrackPopupMenu(GetSystemMenu(wndPtr->hwndSelf, FALSE),
272 TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
273 pt.x, pt.y, 0, wndPtr->hwndSelf, NULL);
275 break;
277 case WM_NCACTIVATE:
278 return NC_HandleNCActivate( wndPtr, wParam );
280 case WM_NCDESTROY:
281 if (wndPtr->text) HeapFree( SystemHeap, 0, wndPtr->text );
282 wndPtr->text = NULL;
283 if (wndPtr->pVScroll) HeapFree( SystemHeap, 0, wndPtr->pVScroll );
284 if (wndPtr->pHScroll) HeapFree( SystemHeap, 0, wndPtr->pHScroll );
285 wndPtr->pVScroll = wndPtr->pHScroll = NULL;
286 return 0;
288 case WM_PRINT:
289 DEFWND_Print(wndPtr, (HDC)wParam, lParam);
290 return 0;
292 case WM_PAINTICON:
293 case WM_PAINT:
295 PAINTSTRUCT16 ps;
296 HDC16 hdc = BeginPaint16( wndPtr->hwndSelf, &ps );
297 if( hdc )
299 if( (wndPtr->dwStyle & WS_MINIMIZE) && wndPtr->class->hIcon )
301 int x = (wndPtr->rectWindow.right - wndPtr->rectWindow.left -
302 GetSystemMetrics(SM_CXICON))/2;
303 int y = (wndPtr->rectWindow.bottom - wndPtr->rectWindow.top -
304 GetSystemMetrics(SM_CYICON))/2;
305 TRACE("Painting class icon: vis rect=(%i,%i - %i,%i)\n",
306 ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom );
307 DrawIcon( hdc, x, y, wndPtr->class->hIcon );
309 EndPaint16( wndPtr->hwndSelf, &ps );
311 return 0;
314 case WM_SYNCPAINT:
315 if (wndPtr->hrgnUpdate)
317 RedrawWindow ( wndPtr->hwndSelf, 0, wndPtr->hrgnUpdate,
318 RDW_ERASENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
320 return 0;
322 case WM_SETREDRAW:
323 DEFWND_SetRedraw( wndPtr, wParam );
324 return 0;
326 case WM_CLOSE:
327 DestroyWindow( wndPtr->hwndSelf );
328 return 0;
330 case WM_MOUSEACTIVATE:
331 if (wndPtr->dwStyle & WS_CHILD)
333 LONG ret = SendMessage16( wndPtr->parent->hwndSelf,
334 WM_MOUSEACTIVATE, wParam, lParam );
335 if (ret) return ret;
338 /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
339 return (LOWORD(lParam) >= HTCLIENT) ? MA_ACTIVATE : MA_NOACTIVATE;
341 case WM_ACTIVATE:
342 /* The default action in Windows is to set the keyboard focus to
343 * the window, if it's being activated and not minimized */
344 if (LOWORD(wParam) != WA_INACTIVE) {
345 if (!(wndPtr->dwStyle & WS_MINIMIZE))
346 SetFocus(wndPtr->hwndSelf);
348 break;
350 case WM_MOUSEWHEEL:
351 if (wndPtr->dwStyle & WS_CHILD)
353 return SendMessageA( wndPtr->parent->hwndSelf,
354 WM_MOUSEWHEEL, wParam, lParam );
356 break;
358 case WM_ERASEBKGND:
359 case WM_ICONERASEBKGND:
361 RECT rect;
363 if (!wndPtr->class->hbrBackground) return 0;
365 /* Since WM_ERASEBKGND may receive either a window dc or a */
366 /* client dc, the area to be erased has to be retrieved from */
367 /* the device context. */
368 GetClipBox( (HDC)wParam, &rect );
370 /* Always call the Win32 variant of FillRect even on Win16,
371 * since despite the fact that Win16, as well as Win32,
372 * supports special background brushes for a window class,
373 * the Win16 variant of FillRect does not.
375 FillRect( (HDC) wParam, &rect, wndPtr->class->hbrBackground);
376 return 1;
379 case WM_GETDLGCODE:
380 return 0;
382 case WM_CTLCOLORMSGBOX:
383 case WM_CTLCOLOREDIT:
384 case WM_CTLCOLORLISTBOX:
385 case WM_CTLCOLORBTN:
386 case WM_CTLCOLORDLG:
387 case WM_CTLCOLORSTATIC:
388 case WM_CTLCOLORSCROLLBAR:
389 return (LRESULT)DEFWND_ControlColor( (HDC)wParam, msg - WM_CTLCOLORMSGBOX );
391 case WM_CTLCOLOR:
392 return (LRESULT)DEFWND_ControlColor( (HDC)wParam, HIWORD(lParam) );
394 case WM_GETTEXTLENGTH:
395 if (wndPtr->text) return (LRESULT)strlenW(wndPtr->text);
396 return 0;
398 case WM_SETCURSOR:
399 if (wndPtr->dwStyle & WS_CHILD)
400 if (SendMessage16(wndPtr->parent->hwndSelf, WM_SETCURSOR,
401 wParam, lParam))
402 return TRUE;
403 return NC_HandleSetCursor( wndPtr->hwndSelf, wParam, lParam );
405 case WM_SYSCOMMAND:
407 POINT pt;
408 pt.x = SLOWORD(lParam);
409 pt.y = SHIWORD(lParam);
410 return NC_HandleSysCommand( wndPtr->hwndSelf, wParam, pt );
413 case WM_KEYDOWN:
414 if(wParam == VK_F10) iF10Key = VK_F10;
415 break;
417 case WM_SYSKEYDOWN:
418 if( HIWORD(lParam) & KEYDATA_ALT )
420 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
421 if( wParam == VK_MENU && !iMenuSysKey )
422 iMenuSysKey = 1;
423 else
424 iMenuSysKey = 0;
426 iF10Key = 0;
428 if( wParam == VK_F4 ) /* try to close the window */
430 HWND hWnd = WIN_GetTopParent( wndPtr->hwndSelf );
431 wndPtr = WIN_FindWndPtr( hWnd );
432 if( wndPtr && !(wndPtr->class->style & CS_NOCLOSE) )
433 PostMessage16( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
434 WIN_ReleaseWndPtr(wndPtr);
437 else if( wParam == VK_F10 )
438 iF10Key = 1;
439 else
440 if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
441 SendMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND,
442 (WPARAM16)SC_KEYMENU, (LPARAM)VK_SPACE);
443 break;
445 case WM_KEYUP:
446 case WM_SYSKEYUP:
447 /* Press and release F10 or ALT */
448 if (((wParam == VK_MENU) && iMenuSysKey) ||
449 ((wParam == VK_F10) && iF10Key))
450 SendMessage16( WIN_GetTopParent(wndPtr->hwndSelf),
451 WM_SYSCOMMAND, SC_KEYMENU, 0L );
452 iMenuSysKey = iF10Key = 0;
453 break;
455 case WM_SYSCHAR:
456 iMenuSysKey = 0;
457 if (wParam == VK_RETURN && (wndPtr->dwStyle & WS_MINIMIZE))
459 PostMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND,
460 (WPARAM16)SC_RESTORE, 0L );
461 break;
463 if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
465 if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
466 if (wParam == VK_SPACE && (wndPtr->dwStyle & WS_CHILD))
467 SendMessage16( wndPtr->parent->hwndSelf, msg, wParam, lParam );
468 else
469 SendMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND,
470 (WPARAM16)SC_KEYMENU, (LPARAM)(DWORD)wParam );
472 else /* check for Ctrl-Esc */
473 if (wParam != VK_ESCAPE) MessageBeep(0);
474 break;
476 case WM_SHOWWINDOW:
477 if (!lParam) return 0; /* sent from ShowWindow */
478 if (!(wndPtr->dwStyle & WS_POPUP) || !wndPtr->owner) return 0;
479 if ((wndPtr->dwStyle & WS_VISIBLE) && wParam) return 0;
480 else if (!(wndPtr->dwStyle & WS_VISIBLE) && !wParam) return 0;
481 ShowWindow( wndPtr->hwndSelf, wParam ? SW_SHOWNOACTIVATE : SW_HIDE );
482 break;
484 case WM_CANCELMODE:
485 if (wndPtr->parent == WIN_GetDesktop()) EndMenu();
486 if (GetCapture() == wndPtr->hwndSelf) ReleaseCapture();
487 WIN_ReleaseDesktop();
488 break;
490 case WM_VKEYTOITEM:
491 case WM_CHARTOITEM:
492 return -1;
494 case WM_DROPOBJECT:
495 return DRAG_FILE;
497 case WM_QUERYDROPOBJECT:
498 if (wndPtr->dwExStyle & WS_EX_ACCEPTFILES) return 1;
499 break;
501 case WM_QUERYDRAGICON:
503 HICON16 hIcon=0;
504 UINT16 len;
506 if( (hIcon=wndPtr->class->hCursor) ) return (LRESULT)hIcon;
507 for(len=1; len<64; len++)
508 if((hIcon=LoadIcon16(wndPtr->hInstance,MAKEINTRESOURCE16(len))))
509 return (LRESULT)hIcon;
510 return (LRESULT)LoadIcon16(0,IDI_APPLICATION16);
512 break;
514 case WM_ISACTIVEICON:
515 return ((wndPtr->flags & WIN_NCACTIVATED) != 0);
517 case WM_NOTIFYFORMAT:
518 if (IsWindowUnicode(wndPtr->hwndSelf)) return NFR_UNICODE;
519 else return NFR_ANSI;
521 case WM_QUERYOPEN:
522 case WM_QUERYENDSESSION:
523 return 1;
525 case WM_SETICON:
527 int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
528 HICON16 hOldIcon = GetClassLongA(wndPtr->hwndSelf, index);
529 SetClassLongA(wndPtr->hwndSelf, index, lParam);
531 SetWindowPos(wndPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED
532 | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE
533 | SWP_NOZORDER);
535 if( wndPtr->flags & WIN_NATIVE )
536 wndPtr->pDriver->pSetHostAttr(wndPtr, HAK_ICONS, 0);
538 return hOldIcon;
541 case WM_GETICON:
543 int index = (wParam != ICON_SMALL) ? GCL_HICON : GCL_HICONSM;
544 return GetClassLongA(wndPtr->hwndSelf, index);
547 case WM_HELP:
548 SendMessageA( wndPtr->parent->hwndSelf, msg, wParam, lParam );
549 break;
552 return 0;
557 /***********************************************************************
558 * DefWindowProc16 (USER.107)
560 LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
561 LPARAM lParam )
563 WND * wndPtr = WIN_FindWndPtr( hwnd );
564 LRESULT result = 0;
566 if (!wndPtr) return 0;
567 SPY_EnterMessage( SPY_DEFWNDPROC16, hwnd, msg, wParam, lParam );
569 switch(msg)
571 case WM_NCCREATE:
573 CREATESTRUCT16 *cs = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam);
574 if (cs->lpszName)
575 DEFWND_SetTextA( wndPtr, (LPCSTR)PTR_SEG_TO_LIN(cs->lpszName) );
576 result = 1;
578 break;
580 case WM_NCCALCSIZE:
582 RECT rect32;
583 CONV_RECT16TO32( (RECT16 *)PTR_SEG_TO_LIN(lParam), &rect32 );
584 result = NC_HandleNCCalcSize( wndPtr, &rect32 );
585 CONV_RECT32TO16( &rect32, (RECT16 *)PTR_SEG_TO_LIN(lParam) );
587 break;
589 case WM_WINDOWPOSCHANGING:
590 result = WINPOS_HandleWindowPosChanging16( wndPtr,
591 (WINDOWPOS16 *)PTR_SEG_TO_LIN(lParam) );
592 break;
594 case WM_WINDOWPOSCHANGED:
596 WINDOWPOS16 * winPos = (WINDOWPOS16 *)PTR_SEG_TO_LIN(lParam);
597 DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags );
599 break;
601 case WM_GETTEXT:
602 if (wParam && wndPtr->text)
604 lstrcpynWtoA( (LPSTR)PTR_SEG_TO_LIN(lParam), wndPtr->text, wParam );
605 result = (LRESULT)strlen( (LPSTR)PTR_SEG_TO_LIN(lParam) );
607 break;
609 case WM_SETTEXT:
610 DEFWND_SetTextA( wndPtr, (LPCSTR)PTR_SEG_TO_LIN(lParam) );
611 if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION )
612 NC_HandleNCPaint( hwnd , (HRGN)1 );
613 break;
615 default:
616 result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam );
617 break;
620 WIN_ReleaseWndPtr(wndPtr);
621 SPY_ExitMessage( SPY_RESULT_DEFWND16, hwnd, msg, result, wParam, lParam );
622 return result;
626 /***********************************************************************
627 * DefWindowProcA [USER32.126]
630 LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam,
631 LPARAM lParam )
633 WND * wndPtr = WIN_FindWndPtr( hwnd );
634 LRESULT result = 0;
636 if (!wndPtr) return 0;
637 SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
639 switch(msg)
641 case WM_NCCREATE:
643 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
644 if (cs->lpszName) DEFWND_SetTextA( wndPtr, cs->lpszName );
645 result = 1;
647 break;
649 case WM_NCCALCSIZE:
650 result = NC_HandleNCCalcSize( wndPtr, (RECT *)lParam );
651 break;
653 case WM_WINDOWPOSCHANGING:
654 result = WINPOS_HandleWindowPosChanging( wndPtr,
655 (WINDOWPOS *)lParam );
656 break;
658 case WM_WINDOWPOSCHANGED:
660 WINDOWPOS * winPos = (WINDOWPOS *)lParam;
661 DEFWND_HandleWindowPosChanged( wndPtr, winPos->flags );
663 break;
665 case WM_GETTEXT:
666 if (wParam && wndPtr->text)
668 lstrcpynWtoA( (LPSTR)lParam, wndPtr->text, wParam );
669 result = (LRESULT)strlen( (LPSTR)lParam );
671 break;
673 case WM_SETTEXT:
674 DEFWND_SetTextA( wndPtr, (LPCSTR)lParam );
675 if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION )
676 NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
677 break;
679 default:
680 result = DEFWND_DefWinProc( wndPtr, msg, wParam, lParam );
681 break;
684 WIN_ReleaseWndPtr(wndPtr);
685 SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam );
686 return result;
690 /***********************************************************************
691 * DefWindowProcW [USER32.127] Calls default window message handler
693 * Calls default window procedure for messages not processed
694 * by application.
696 * RETURNS
697 * Return value is dependent upon the message.
699 LRESULT WINAPI DefWindowProcW(
700 HWND hwnd, /* [in] window procedure recieving message */
701 UINT msg, /* [in] message identifier */
702 WPARAM wParam, /* [in] first message parameter */
703 LPARAM lParam ) /* [in] second message parameter */
705 WND * wndPtr = WIN_FindWndPtr( hwnd );
706 LRESULT result = 0;
708 if (!wndPtr) return 0;
709 SPY_EnterMessage( SPY_DEFWNDPROC, hwnd, msg, wParam, lParam );
711 switch(msg)
713 case WM_NCCREATE:
715 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
716 if (cs->lpszName) DEFWND_SetTextW( wndPtr, cs->lpszName );
717 result = 1;
719 break;
721 case WM_GETTEXT:
722 if (wParam && wndPtr->text)
724 lstrcpynW( (LPWSTR)lParam, wndPtr->text, wParam );
725 result = strlenW( (LPWSTR)lParam );
727 break;
729 case WM_SETTEXT:
730 DEFWND_SetTextW( wndPtr, (LPCWSTR)lParam );
731 if( (wndPtr->dwStyle & WS_CAPTION) == WS_CAPTION )
732 NC_HandleNCPaint( hwnd , (HRGN)1 ); /* Repaint caption */
733 break;
735 default:
736 result = DefWindowProcA( hwnd, msg, wParam, lParam );
737 break;
739 WIN_ReleaseWndPtr(wndPtr);
740 SPY_ExitMessage( SPY_RESULT_DEFWND, hwnd, msg, result, wParam, lParam );
741 return result;