2 * Default window procedure
4 * Copyright 1993 Alexandre Julliard
7 static char Copyright[] = "Copyright Alexandre Julliard, 1993";
17 /* #define DEBUG_MESSAGE */
18 /* #undef DEBUG_MESSAGE */
23 #define COLOR_MAX COLOR_BTNHIGHLIGHT
25 extern LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn );
26 extern LONG NC_HandleNCActivate( HWND hwnd, WORD wParam );
27 extern LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params );
28 extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt );
29 extern LONG NC_HandleNCLButtonDown( HWND hwnd, WORD wParam, LONG lParam );
30 extern LONG NC_HandleNCLButtonDblClk( HWND hwnd, WORD wParam, LONG lParam );
31 extern LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt );
32 extern LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam );
33 extern LONG WINPOS_HandleWindowPosChanging( WINDOWPOS *winpos ); /* winpos.c */
36 /***********************************************************************
39 * Set the window text.
41 void DEFWND_SetText( HWND hwnd, LPSTR text )
44 WND *wndPtr = WIN_FindWndPtr( hwnd );
46 if (wndPtr->hText) USER_HEAP_FREE( wndPtr->hText );
47 wndPtr->hText = USER_HEAP_ALLOC( LMEM_MOVEABLE, strlen(text) + 1 );
48 textPtr = (LPSTR) USER_HEAP_ADDR( wndPtr->hText );
49 strcpy( textPtr, text );
54 /***********************************************************************
55 * DefWindowProc (USER.107)
57 LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam )
59 MEASUREITEMSTRUCT *measure;
63 WND * wndPtr = WIN_FindWndPtr( hwnd );
65 dprintf_message(stddeb, "DefWindowProc: %d %d %d %08lx\n",
66 hwnd, msg, wParam, lParam );
72 CREATESTRUCT * createStruct = (CREATESTRUCT *)lParam;
73 if (createStruct->lpszName)
74 DEFWND_SetText( hwnd, createStruct->lpszName );
79 return NC_HandleNCCalcSize( hwnd, (NCCALCSIZE_PARAMS *)lParam );
83 return NC_HandleNCPaint( hwnd, (HRGN)wParam );
86 return NC_HandleNCHitTest( hwnd, MAKEPOINT(lParam) );
88 case WM_NCLBUTTONDOWN:
89 return NC_HandleNCLButtonDown( hwnd, wParam, lParam );
91 case WM_LBUTTONDBLCLK:
92 case WM_NCLBUTTONDBLCLK:
93 return NC_HandleNCLButtonDblClk( hwnd, wParam, lParam );
96 return NC_HandleNCActivate( hwnd, wParam );
99 if (wndPtr->hText) USER_HEAP_FREE(wndPtr->hText);
100 if (wndPtr->hVScroll) USER_HEAP_FREE(wndPtr->hVScroll);
101 if (wndPtr->hHScroll) USER_HEAP_FREE(wndPtr->hHScroll);
102 wndPtr->hText = wndPtr->hVScroll = wndPtr->hHScroll = 0;
107 PAINTSTRUCT paintstruct;
108 BeginPaint( hwnd, &paintstruct );
109 EndPaint( hwnd, &paintstruct );
116 ValidateRect( hwnd, NULL );
117 wndPtr->flags |= WIN_NO_REDRAW;
119 else wndPtr->flags &= ~WIN_NO_REDRAW;
123 DestroyWindow( hwnd );
126 case WM_MOUSEACTIVATE:
127 if (wndPtr->dwStyle & WS_CHILD)
129 LONG ret = SendMessage( wndPtr->hwndParent, WM_MOUSEACTIVATE,
136 if (wParam) SetFocus( hwnd );
139 case WM_WINDOWPOSCHANGING:
140 return WINPOS_HandleWindowPosChanging( (WINDOWPOS *)lParam );
142 case WM_WINDOWPOSCHANGED:
144 WINDOWPOS * winPos = (WINDOWPOS *)lParam;
145 if (!(winPos->flags & SWP_NOMOVE))
146 SendMessage( hwnd, WM_MOVE, 0,
147 MAKELONG( wndPtr->rectClient.left,
148 wndPtr->rectClient.top ));
149 if (!(winPos->flags & SWP_NOSIZE))
150 SendMessage( hwnd, WM_SIZE, SIZE_RESTORED,
151 MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
152 wndPtr->rectClient.bottom-wndPtr->rectClient.top));
157 case WM_ICONERASEBKGND:
159 if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 1;
160 if (!classPtr->wc.hbrBackground) return 1;
161 if (classPtr->wc.hbrBackground <= COLOR_MAX+1)
164 hbrush = CreateSolidBrush(
165 GetSysColor(classPtr->wc.hbrBackground-1));
166 FillWindow( GetParent(hwnd), hwnd, (HDC)wParam, hbrush);
167 DeleteObject (hbrush);
170 FillWindow( GetParent(hwnd), hwnd, (HDC)wParam,
171 classPtr->wc.hbrBackground );
180 if (HIWORD(lParam) == CTLCOLOR_SCROLLBAR)
182 SetBkColor( (HDC)wParam, RGB(255, 255, 255) );
183 SetTextColor( (HDC)wParam, RGB(0, 0, 0) );
184 UnrealizeObject( sysColorObjects.hbrushScrollbar );
185 return sysColorObjects.hbrushScrollbar;
189 SetBkColor( (HDC)wParam, GetSysColor(COLOR_WINDOW) );
190 SetTextColor( (HDC)wParam, GetSysColor(COLOR_WINDOWTEXT) );
191 return sysColorObjects.hbrushWindow;
201 textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
202 if ((int)wParam > (len = strlen(textPtr)))
204 strcpy((char *)lParam, textPtr);
208 lParam = (DWORD)NULL;
213 case WM_GETTEXTLENGTH:
217 textPtr = (LPSTR)USER_HEAP_ADDR(wndPtr->hText);
218 return (DWORD)strlen(textPtr);
224 DEFWND_SetText( hwnd, (LPSTR)lParam );
225 NC_HandleNCPaint( hwnd, (HRGN)1 ); /* Repaint caption */
229 if (wndPtr->dwStyle & WS_CHILD)
230 if (SendMessage(wndPtr->hwndParent, WM_SETCURSOR, wParam, lParam))
232 return NC_HandleSetCursor( hwnd, wParam, lParam );
235 return NC_HandleSysCommand( hwnd, wParam, MAKEPOINT(lParam) );
238 if (wParam == VK_MENU)
239 { /* Send to WS_OVERLAPPED parent. TODO: Handle MDI */
241 for(top=hwnd;GetParent(top)!=0;top=GetParent(top));
242 SendMessage( top, WM_SYSCOMMAND, SC_KEYMENU, 0L );
249 measure = (MEASUREITEMSTRUCT *)lParam;
250 switch(measure->CtlType) {
254 measure->itemHeight = 10;
255 /* printf("defwndproc WM_MEASUREITEM // ODT_COMBOBOX !\n");*/
258 measure->itemHeight = 10;
259 /* printf("defwndproc WM_MEASUREITEM // ODT_LISTBOX !\n");*/