2 * Default window procedure
4 * Copyright 1993 Alexandre Julliard
12 #include "nonclient.h"
16 /* #define DEBUG_MESSAGE */
21 #define COLOR_MAX COLOR_BTNHIGHLIGHT
24 /***********************************************************************
27 * Set the window text.
29 void DEFWND_SetText( HWND hwnd, LPSTR text )
32 WND *wndPtr = WIN_FindWndPtr( hwnd );
35 if (wndPtr->hText) USER_HEAP_FREE( wndPtr->hText );
36 wndPtr->hText = USER_HEAP_ALLOC( strlen(text) + 1 );
37 textPtr = (LPSTR) USER_HEAP_LIN_ADDR( wndPtr->hText );
38 strcpy( textPtr, text );
42 /***********************************************************************
43 * DefWindowProc (USER.107)
45 LRESULT DefWindowProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
50 WND * wndPtr = WIN_FindWndPtr( hwnd );
52 EnterSpyMessage(SPY_DEFWNDPROC,hwnd,msg,wParam,lParam);
58 CREATESTRUCT *createStruct = (CREATESTRUCT*)PTR_SEG_TO_LIN(lParam);
59 if (createStruct->lpszName)
61 (LPSTR)PTR_SEG_TO_LIN(createStruct->lpszName) );
66 return NC_HandleNCCalcSize( hwnd,
67 (NCCALCSIZE_PARAMS *)PTR_SEG_TO_LIN(lParam) );
71 return NC_HandleNCPaint( hwnd );
75 POINT pt = { LOWORD(lParam), HIWORD(lParam) };
76 return NC_HandleNCHitTest( hwnd, pt );
79 case WM_NCLBUTTONDOWN:
80 return NC_HandleNCLButtonDown( hwnd, wParam, lParam );
82 case WM_LBUTTONDBLCLK:
83 case WM_NCLBUTTONDBLCLK:
84 return NC_HandleNCLButtonDblClk( hwnd, wParam, lParam );
87 return NC_HandleNCActivate( hwnd, wParam );
90 if (wndPtr->hText) USER_HEAP_FREE(wndPtr->hText);
91 if (wndPtr->hVScroll) USER_HEAP_FREE(wndPtr->hVScroll);
92 if (wndPtr->hHScroll) USER_HEAP_FREE(wndPtr->hHScroll);
93 wndPtr->hText = wndPtr->hVScroll = wndPtr->hHScroll = 0;
98 PAINTSTRUCT paintstruct;
99 BeginPaint( hwnd, &paintstruct );
100 EndPaint( hwnd, &paintstruct );
107 ValidateRect( hwnd, NULL );
108 wndPtr->flags |= WIN_NO_REDRAW;
110 else wndPtr->flags &= ~WIN_NO_REDRAW;
114 DestroyWindow( hwnd );
117 case WM_MOUSEACTIVATE:
118 if (wndPtr->dwStyle & WS_CHILD)
120 LONG ret = SendMessage( wndPtr->hwndParent, WM_MOUSEACTIVATE,
127 /* LOWORD() needed for WINELIB32 implementation. Should be fine. */
128 if (LOWORD(wParam)!=WA_INACTIVE) SetFocus( hwnd );
131 case WM_WINDOWPOSCHANGING:
132 return WINPOS_HandleWindowPosChanging( (WINDOWPOS *)PTR_SEG_TO_LIN(lParam) );
134 case WM_WINDOWPOSCHANGED:
136 WINDOWPOS * winPos = (WINDOWPOS *)PTR_SEG_TO_LIN(lParam);
137 if (!(winPos->flags & SWP_NOMOVE))
138 SendMessage( hwnd, WM_MOVE, 0,
139 MAKELONG( wndPtr->rectClient.left,
140 wndPtr->rectClient.top ));
141 if (!(winPos->flags & SWP_NOSIZE))
142 SendMessage( hwnd, WM_SIZE, SIZE_RESTORED,
143 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
144 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
149 case WM_ICONERASEBKGND:
151 if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 0;
152 if (!classPtr->wc.hbrBackground) return 0;
153 if (classPtr->wc.hbrBackground <= (HBRUSH)(COLOR_MAX+1))
156 hbrush = CreateSolidBrush(
157 GetSysColor(((DWORD)classPtr->wc.hbrBackground)-1));
158 FillWindow( GetParent(hwnd), hwnd, (HDC)wParam, hbrush);
159 DeleteObject (hbrush);
162 FillWindow( GetParent(hwnd), hwnd, (HDC)wParam,
163 classPtr->wc.hbrBackground );
170 case WM_CTLCOLORMSGBOX:
171 case WM_CTLCOLOREDIT:
172 case WM_CTLCOLORLISTBOX:
175 case WM_CTLCOLORSTATIC:
176 SetBkColor( (HDC)wParam, GetSysColor(COLOR_WINDOW) );
177 SetTextColor( (HDC)wParam, GetSysColor(COLOR_WINDOWTEXT) );
178 return (LONG)sysColorObjects.hbrushWindow;
180 case WM_CTLCOLORSCROLLBAR:
181 SetBkColor( (HDC)wParam, RGB(255, 255, 255) );
182 SetTextColor( (HDC)wParam, RGB(0, 0, 0) );
183 UnrealizeObject( sysColorObjects.hbrushScrollbar );
184 return (LONG)sysColorObjects.hbrushScrollbar;
188 if (HIWORD(lParam) == CTLCOLOR_SCROLLBAR)
190 SetBkColor( (HDC)wParam, RGB(255, 255, 255) );
191 SetTextColor( (HDC)wParam, RGB(0, 0, 0) );
192 UnrealizeObject( sysColorObjects.hbrushScrollbar );
193 return (LONG)sysColorObjects.hbrushScrollbar;
197 SetBkColor( (HDC)wParam, GetSysColor(COLOR_WINDOW) );
198 SetTextColor( (HDC)wParam, GetSysColor(COLOR_WINDOWTEXT) );
199 return (LONG)sysColorObjects.hbrushWindow;
209 textPtr = (LPSTR)USER_HEAP_LIN_ADDR(wndPtr->hText);
210 if ((int)wParam > (len = strlen(textPtr)))
212 strcpy((char *)PTR_SEG_TO_LIN(lParam), textPtr);
220 case WM_GETTEXTLENGTH:
224 textPtr = (LPSTR)USER_HEAP_LIN_ADDR(wndPtr->hText);
225 return (DWORD)strlen(textPtr);
231 DEFWND_SetText( hwnd, (LPSTR)PTR_SEG_TO_LIN(lParam) );
232 NC_HandleNCPaint( hwnd ); /* Repaint caption */
236 if (wndPtr->dwStyle & WS_CHILD)
237 if (SendMessage(wndPtr->hwndParent, WM_SETCURSOR, wParam, lParam))
239 return NC_HandleSetCursor( hwnd, wParam, lParam );
243 POINT pt = { LOWORD(lParam), HIWORD(lParam) };
244 return NC_HandleSysCommand( hwnd, wParam, pt );
248 if (wParam == VK_MENU)
249 { /* Send to WS_OVERLAPPED parent. TODO: Handle MDI */
250 SendMessage( WIN_GetTopParent(hwnd), WM_SYSCOMMAND,