2 * Default window procedure
4 * Copyright 1993 Alexandre Julliard
6 static char Copyright[] = "Copyright Alexandre Julliard, 1993";
15 #include "nonclient.h"
19 /* #define DEBUG_MESSAGE */
23 #define COLOR_MAX COLOR_BTNHIGHLIGHT
25 /***********************************************************************
28 * Set the window text.
30 void DEFWND_SetText( HWND hwnd
, LPSTR text
)
33 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
35 if (wndPtr
->hText
) USER_HEAP_FREE( wndPtr
->hText
);
36 wndPtr
->hText
= USER_HEAP_ALLOC( LMEM_MOVEABLE
, strlen(text
) + 1 );
37 textPtr
= (LPSTR
) USER_HEAP_ADDR( wndPtr
->hText
);
38 strcpy( textPtr
, text
);
43 /***********************************************************************
44 * DefWindowProc (USER.107)
46 LONG
DefWindowProc( HWND hwnd
, WORD msg
, WORD wParam
, LONG lParam
)
48 MEASUREITEMSTRUCT
*measure
;
52 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
54 dprintf_message(stddeb
, "DefWindowProc: %d %d %d %08lx\n",
55 hwnd
, msg
, wParam
, lParam
);
61 CREATESTRUCT
* createStruct
= (CREATESTRUCT
*)lParam
;
62 if (createStruct
->lpszName
)
63 DEFWND_SetText( hwnd
, createStruct
->lpszName
);
68 return NC_HandleNCCalcSize( hwnd
, (NCCALCSIZE_PARAMS
*)lParam
);
72 return NC_HandleNCPaint( hwnd
);
75 return NC_HandleNCHitTest( hwnd
, MAKEPOINT(lParam
) );
77 case WM_NCLBUTTONDOWN
:
78 return NC_HandleNCLButtonDown( hwnd
, wParam
, lParam
);
80 case WM_LBUTTONDBLCLK
:
81 case WM_NCLBUTTONDBLCLK
:
82 return NC_HandleNCLButtonDblClk( hwnd
, wParam
, lParam
);
85 return NC_HandleNCActivate( hwnd
, wParam
);
88 if (wndPtr
->hText
) USER_HEAP_FREE(wndPtr
->hText
);
89 if (wndPtr
->hVScroll
) USER_HEAP_FREE(wndPtr
->hVScroll
);
90 if (wndPtr
->hHScroll
) USER_HEAP_FREE(wndPtr
->hHScroll
);
91 wndPtr
->hText
= wndPtr
->hVScroll
= wndPtr
->hHScroll
= 0;
96 PAINTSTRUCT paintstruct
;
97 BeginPaint( hwnd
, &paintstruct
);
98 EndPaint( hwnd
, &paintstruct
);
105 ValidateRect( hwnd
, NULL
);
106 wndPtr
->flags
|= WIN_NO_REDRAW
;
108 else wndPtr
->flags
&= ~WIN_NO_REDRAW
;
112 DestroyWindow( hwnd
);
115 case WM_MOUSEACTIVATE
:
116 if (wndPtr
->dwStyle
& WS_CHILD
)
118 LONG ret
= SendMessage( wndPtr
->hwndParent
, WM_MOUSEACTIVATE
,
125 if (wParam
) SetFocus( hwnd
);
128 case WM_WINDOWPOSCHANGING
:
129 return WINPOS_HandleWindowPosChanging( (WINDOWPOS
*)lParam
);
131 case WM_WINDOWPOSCHANGED
:
133 WINDOWPOS
* winPos
= (WINDOWPOS
*)lParam
;
134 if (!(winPos
->flags
& SWP_NOMOVE
))
135 SendMessage( hwnd
, WM_MOVE
, 0,
136 MAKELONG( wndPtr
->rectClient
.left
,
137 wndPtr
->rectClient
.top
));
138 if (!(winPos
->flags
& SWP_NOSIZE
))
139 SendMessage( hwnd
, WM_SIZE
, SIZE_RESTORED
,
140 MAKELONG(wndPtr
->rectClient
.right
-wndPtr
->rectClient
.left
,
141 wndPtr
->rectClient
.bottom
-wndPtr
->rectClient
.top
));
146 case WM_ICONERASEBKGND
:
148 if (!(classPtr
= CLASS_FindClassPtr( wndPtr
->hClass
))) return 0;
149 if (!classPtr
->wc
.hbrBackground
) return 0;
150 if (classPtr
->wc
.hbrBackground
<= COLOR_MAX
+1)
153 hbrush
= CreateSolidBrush(
154 GetSysColor(classPtr
->wc
.hbrBackground
-1));
155 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
, hbrush
);
156 DeleteObject (hbrush
);
159 FillWindow( GetParent(hwnd
), hwnd
, (HDC
)wParam
,
160 classPtr
->wc
.hbrBackground
);
169 if (HIWORD(lParam
) == CTLCOLOR_SCROLLBAR
)
171 SetBkColor( (HDC
)wParam
, RGB(255, 255, 255) );
172 SetTextColor( (HDC
)wParam
, RGB(0, 0, 0) );
173 UnrealizeObject( sysColorObjects
.hbrushScrollbar
);
174 return sysColorObjects
.hbrushScrollbar
;
178 SetBkColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOW
) );
179 SetTextColor( (HDC
)wParam
, GetSysColor(COLOR_WINDOWTEXT
) );
180 return sysColorObjects
.hbrushWindow
;
190 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
191 if ((int)wParam
> (len
= strlen(textPtr
)))
193 strcpy((char *)lParam
, textPtr
);
197 lParam
= (DWORD
)NULL
;
202 case WM_GETTEXTLENGTH
:
206 textPtr
= (LPSTR
)USER_HEAP_ADDR(wndPtr
->hText
);
207 return (DWORD
)strlen(textPtr
);
213 DEFWND_SetText( hwnd
, (LPSTR
)lParam
);
214 NC_HandleNCPaint( hwnd
); /* Repaint caption */
218 if (wndPtr
->dwStyle
& WS_CHILD
)
219 if (SendMessage(wndPtr
->hwndParent
, WM_SETCURSOR
, wParam
, lParam
))
221 return NC_HandleSetCursor( hwnd
, wParam
, lParam
);
224 return NC_HandleSysCommand( hwnd
, wParam
, MAKEPOINT(lParam
) );
227 if (wParam
== VK_MENU
)
228 { /* Send to WS_OVERLAPPED parent. TODO: Handle MDI */
230 for(top
=hwnd
;GetParent(top
)!=0;top
=GetParent(top
));
231 SendMessage( top
, WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
238 measure
= (MEASUREITEMSTRUCT
*)lParam
;
239 switch(measure
->CtlType
) {
243 measure
->itemHeight
= 10;
244 /* printf("defwndproc WM_MEASUREITEM // ODT_COMBOBOX !\n");*/
247 measure
->itemHeight
= 10;
248 /* printf("defwndproc WM_MEASUREITEM // ODT_LISTBOX !\n");*/